Thread: Header File Issue CodeBlocks

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    28

    Header File Issue CodeBlocks

    I am using (or better stated attempting to use) CodeBlocks IDE. I have source code that has been successfully built in Borland C, Pelles C and Visual Studio. When I try to build this using CodeBlocks, my header files are not being compiled (they are actually shaded in the workspace header folder). I have them listed in the workspace and in each source file where the header files are needed, they are listed like:

    #include "firstheader.h"
    #include "secondheader.h"

    etc.

    But the functions in those headers are not being read. I am getting the no prototype error and, as I said, the headers are shaded in the IDE.

    What am I doing wrong?

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Header files are NOT normally compiled.
    What is the Compiler you are using?
    NOTE: Code::Blocks IS NOT a Compiler.

    I suggest turning on Full Compiler Logging in Code::Blocks.
    FAQ-Compiling (errors) - CodeBlocks

    What error is the "no prototype error"?

    Tim S.
    Last edited by stahta01; 11-18-2011 at 01:04 PM.

  3. #3
    Registered User
    Join Date
    Nov 2011
    Posts
    28
    Tim,

    Thank you for your reply. It is not a prototype error. Sorry about the inaccuracy there. I was thinking of something else while writing. I am getting "undefined reference" errors. I do have logging set and I am using the GNC GCC compiler.

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Are the header files where the compiler expects to find them?

  5. #5
    Registered User
    Join Date
    Nov 2011
    Posts
    28
    Hi Tater,

    That's a good question. Doesn't the use of double-quotes "" around the filename indicate to the compiler that the header files are in the source directory?

  6. #6
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    "undefined reference" is usually a linking error. The compiler (technically the linker) can't find some object file or library it's looking for. Perhaps you don't have all the source files (and thus the object files) specified as part of your project, or perhaps you're not specifying library search directories or library names correctly.

    Yes, you're right about the double quotes referring to the current directory. However, if the compiler couldn't find the header files, you would probably see some warning message about missing prototypes.

  7. #7
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by mathguy View Post
    Hi Tater,

    That's a good question. Doesn't the use of double-quotes "" around the filename indicate to the compiler that the header files are in the source directory?
    Yep... and are they?

  8. #8
    Registered User
    Join Date
    Nov 2011
    Posts
    28
    Quote Originally Posted by CommonTater View Post
    Yep... and are they?
    They are. I think that, as anduril said, it is a linker error. But, I've got the linker pointing to the .dll.a file. Still no go.

  9. #9
    Registered User
    Join Date
    Mar 2011
    Posts
    546
    Quote Originally Posted by CommonTater View Post
    Yep... and are they?
    double quotes doesn't meant that, not exactly. it's where the compiler will look first then in the include paths, although preprocessors vary on how they treat "" and <>. here is what GNU does

    #include <file>
    This variant is used for system header files. It searches for a file named file in a standard list of system directories. You can prepend directories to this list with the -I option (see Invocation).

    #include "file"
    This variant is used for header files of your own program. It searches for a file named file first in the directory containing the current file, then in the quote directories and then the same directories used for <file>. You can prepend directories to the list of quote directories with the -iquote option.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 05-20-2011, 04:22 AM
  2. CodeBlocks IDE file management
    By ~Kyo~ in forum Windows Programming
    Replies: 3
    Last Post: 02-08-2011, 11:23 AM
  3. CodeBlocks preprocessor file
    By MattJ812 in forum C++ Programming
    Replies: 23
    Last Post: 01-17-2011, 10:33 AM
  4. Replies: 30
    Last Post: 06-19-2006, 12:35 AM