Author Topic: Noob question about inlcuding .h files  (Read 3884 times)

iio

  • Guest
Noob question about inlcuding .h files
« on: September 09, 2008, 02:01:40 pm »
I have a Bullet demo that I know works that won't compile in C::B. I have included the .h files' directory in the Porject's Build options and it has worked for other header files but doesn't for some. Error is:

No such file or directory


I have even tried including the files in the project hierarchy but to no avail. I ma new to C::B so am I missing something?



Thanks,
iio

Offline DrewBoo

  • Multiple posting newcomer
  • *
  • Posts: 110
Re: Noob question about inlcuding .h files
« Reply #1 on: September 09, 2008, 04:18:00 pm »
Can you tell us more, iio?  Which includes work?  Which don't? Can we see the code?  What directories work?  Which directories don't work?

Offline gomer

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: Noob question about inlcuding .h files
« Reply #2 on: November 27, 2008, 06:01:22 pm »
Hi,

I'm new to Code::Blocks, but not to C++.  Code::Blocks seems to be a good ide, but I'm having some trouble with headers in projects similar to that noted by iio.  That is : the gnu C++ compiler reports the message "No such file or directory" even thought the header exists in the project in the headers folder.  The problem can be solved including the folder that contains the header in the "Search directories" under build options.  Obviously, the header file could have been located using the entry under the project->headers folder, but it wasn't.  This raises the question : what is the headers folder used for if not to locate headers?  Could anyone provide any insight here?

thanx - in advance

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Noob question about inlcuding .h files
« Reply #3 on: November 27, 2008, 06:49:00 pm »
The "Source", "Headers" ... folders are virtual folders, that make it easier to handle a great amout of source-files.

You can switch them on and off. Just right-click your project, chose "Project tree" and check or uncheck "Categorize by file types".

They have nothing to do wit the search-directories for the compiler and/or the linker.

EDIT:
Here is how gcc searches for includes:

Quote from cpp-manual:
Quote
#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.
« Last Edit: November 27, 2008, 06:51:51 pm by jens »

Offline gomer

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: Noob question about inlcuding .h files
« Reply #4 on: November 27, 2008, 10:10:44 pm »
First of all - thanx for the incredibly quick reply!

Ok - I think I've got it.  The Sources / Headers virtual folders only separate the various project inputs by file type.  C/C++ sources get translated into object files via a compiler when building, but .H files don't.  I.E. header files and all non source code file types are ignored as project inputs even though they appear  as such in the project hierarchy.

thanx again.

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Noob question about inlcuding .h files
« Reply #5 on: November 27, 2008, 10:20:27 pm »
First of all - thanx for the incredibly quick reply!

Ok - I think I've got it.  The Sources / Headers virtual folders only separate the various project inputs by file type.  C/C++ sources get translated into object files via a compiler when building, but .H files don't.  I.E. header files and all non source code file types are ignored as project inputs even though they appear  as such in the project hierarchy.

thanx again.

No they are not ignored (at least not if they get included with the #include-statement), but as posted over and over again:

this is not a general programming forum, only C::B related questions should be asked.

Read a good book/tutorial to learn something about the basics of how compiler, linker etc. work.

Offline gomer

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: Noob question about inlcuding .h files
« Reply #6 on: November 28, 2008, 08:56:45 pm »
This is a C::B issue.  Project files belong to C::B and not to compilers nor linkers and, btw, I am familiar with a number of compilers and linkers on a number of different platforms.  The question was/is : what does C::B do (if anything) with .H/.HPP files listed under projects? This question could also be extended to .lib, .dll, .xxx, etc. files. I.E. any files other than .c, .cpp, and .rc (perhaps).