Author Topic: include header files in different directories  (Read 27131 times)

Offline wzyjy

  • Single posting newcomer
  • *
  • Posts: 9
include header files in different directories
« on: December 13, 2010, 11:18:05 pm »
This may be a stupid question:

I have a big folder(say source_root) containing .cc files and .h files in many different sub-folders. When I tried to build the whole project, say 1.cc in subfolder A wants to include b.h in subfolder B, it just could not find file b.h.

Is there anyway to solve this issue?
I tried to add source_root into additional search path (under the project properties->C/C++ parser options), but it didn't work...

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: include header files in different directories
« Reply #1 on: December 13, 2010, 11:39:16 pm »
Add all folders, that contain headers you want to include (except for system standard folders) to "Project -> Build options... -> [your project _not_ the targets] -> Search directories -> Compiler"

Offline wzyjy

  • Single posting newcomer
  • *
  • Posts: 9
Re: include header files in different directories
« Reply #2 on: December 14, 2010, 12:52:29 am »
Thanks, I already did that and it worked.
The only thing is I have to add all the sub-folders manually, is there any way to do it recursively? (If I have 100+ sub-folders, do I have to add them all manually?)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7785
    • My Best Post
Re: include header files in different directories
« Reply #3 on: December 14, 2010, 01:28:24 am »
Try doing

Settings -> "Compiler And Debugger" [SELECT YOUR COMPILER]
Tab "Other Settings] Check mark "Explicitly add Currently Compiling File's Directory to Compiler search path"
This should reduce the number of paths to add.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org