Author Topic: Can't find #include files  (Read 10300 times)

Offline simonl

  • Single posting newcomer
  • *
  • Posts: 7
Can't find #include files
« on: November 28, 2008, 07:33:38 pm »
I've just installed C::B and tried to transfer some existing code to it.  I split it into two projects:

lib      - builds a library which is used by ...

tests  which consists of s set of separate, single file programs which test various aspects of the lib and which depends upon it.


The lib build worked fine first time (congrats to C::B team - a very professional product).  The tests project dependency works fine.

The test programs use the same headers as the lib project so I added the header directory to project tests Properties ... -> c/c++ parser options as an additional search path.  Just to be doubly sure I added it to the Build options... ->search directories->compiler  tab (I'm not yet sure what the difference is between the two places).  But it doesn't find the include files.  

I turned full logging on and the g++ command for the first test is:

mingw32-g++.exe   -c P:\eacp\test\polydomaintest.cpp -o \polydomaintest.o

I'd expect it to also have:   -Ip:\eacp\include 

Also what's with -o \polydomaintest.o ... shouldn't it be -o .\polydomaintest.o or just -o polydomaintest.o

Any ideas what I'm doing wrong?

Thanks

Simon

« Last Edit: November 28, 2008, 07:48:09 pm by simonl »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Can't find #include files
« Reply #1 on: November 28, 2008, 10:00:07 pm »
Any ideas what I'm doing wrong?
Please post your project file and we most likely can tell.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline simonl

  • Single posting newcomer
  • *
  • Posts: 7
Re: Can't find #include files
« Reply #2 on: November 29, 2008, 11:23:17 am »
Thanks for the quick reply.  Here's the "test" project file. 

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
   <FileVersion major="1" minor="6" />
   <Project>
      <Option title="test" />
      <Option platforms="Windows;" />
      <Option pch_mode="2" />
      <Option compiler="gcc" />
      <Build>
         <Target title="Debug">
            <Option type="4" />
            <Option compiler="gcc" />
            <Option projectIncludeDirsRelation="2" />
            <Compiler>
               <Add option="-g" />
               <Add directory="P:\eacp\include" />
               <Add directory="..\include" />
            </Compiler>
         </Target>
         <Target title="Release">
            <Option output="bin\Release\test" prefix_auto="1" extension_auto="1" />
            <Option object_output="obj\Release\" />
            <Option type="1" />
            <Option compiler="gcc" />
            <Compiler>
               <Add option="-O2" />
               <Add directory="P:\eacp\include" />
            </Compiler>
            <Linker>
               <Add option="-s" />
            </Linker>
         </Target>
      </Build>
      <Compiler>
         <Add option="-Wall" />
         <Add directory="P:\eacp\include" />
         <Add directory="..\include" />
      </Compiler>
      <Unit filename="intervalTest.cpp" />
      <Unit filename="polydomaintest.cpp" />
      <Unit filename="polytest.cpp" />
      <Unit filename="simpletest.cpp" />
      <Unit filename="traittest.cpp" />
      <Extensions>
         <code_completion>
            <search_path add="..\include" />
         </code_completion>
         <debugger />
      </Extensions>
   </Project>
</CodeBlocks_project_file>

Simon

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Can't find #include files
« Reply #3 on: November 29, 2008, 11:58:48 am »
Change projects "Properties... -> Build targets -> Debug -> Type" to "Console application" or whatever type it should be. Don't use "Commands only" !!

Btw. the "Release" build target seems to be correct.

Offline simonl

  • Single posting newcomer
  • *
  • Posts: 7
Re: Can't find #include files
« Reply #4 on: November 29, 2008, 01:28:11 pm »
Thanks.  The project contains lots of separate programs - I'd guessed (wrongly) that "Commands Only" wouldn't try and link everything together.  Is it easier to just provide a make file to produce lots of exe files in one directory? Before trying C::B I tended to use ad hoc make files but thought maybe I wouldn't need then any more.

Simon
   


Veremos

  • Guest
Re: Can't find #include files
« Reply #5 on: December 01, 2008, 02:26:55 pm »
I have the same problem, although my are already set to Console application.. I am migrating from Xcode to Code::Blocks for Windows users but when I try to compile the file I'm getting the following error:

Code
ofxCvHaarFinder.h: No such file or directory

CBP-file in which the file in the path to ofxCvHaarFinder.h is present..

Thanks for your help in advance :)

Code
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="Gezichtsherkenning" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Option virtualFolders="addons\;libs\;src\;libs\openframeworks\;libs\openframeworks\app\;libs\openframeworks\communication\;libs\openframeworks\graphics\;libs\openframeworks\sound\;libs\openframeworks\utils\;libs\openframeworks\video\;addons\ofxOpenCV\;addons\ofxOpenCV\src\;libs\faceDetection\;" />
<Build>
<Target title="release">
<Option output="bin\opencvExample" prefix_auto="1" extension_auto="1" />
<Option working_dir="bin" />
<Option object_output="obj\release" />
<Option type="1" />
<Option compiler="gcc" />
</Target>
<Target title="debug">
<Option output="bin\opencvExample_DEBUG" prefix_auto="1" extension_auto="1" />
<Option working_dir="bin" />
<Option object_output="obj\debug\" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
</Build>
<Compiler>
<Add option="-Wno-multichar" />
<Add directory="..\..\..\libs\glu" />
<Add directory="..\..\..\libs\freeType\include" />
<Add directory="..\..\..\libs\freeType\include\freetype2" />
<Add directory="..\..\..\libs\freeImage" />
<Add directory="..\..\..\libs\quicktime\CIncludes" />
<Add directory="..\..\..\libs\RtAudio" />
<Add directory="..\..\..\libs\fmodex\inc" />
<Add directory="..\..\..\libs\videoInput\include" />
<Add directory="..\..\..\libs\glee\include" />
<Add directory="..\..\..\libs\glut" />
<Add directory="..\..\..\libs\openFrameworks" />
<Add directory="..\..\..\libs\openFrameworks\app" />
<Add directory="..\..\..\libs\openFrameworks\graphics" />
<Add directory="..\..\..\libs\openFrameworks\utils" />
<Add directory="..\..\..\libs\openFrameworks\sound" />
<Add directory="..\..\..\libs\openFrameworks\video" />
<Add directory="..\..\..\libs\openFrameworks\communication" />
<Add directory="..\..\..\addons" />
<Add directory="..\..\..\addons\ofxObjLoader\src" />
<Add directory="..\..\..\addons\ofxDirList\src" />
<Add directory="..\..\..\addons\ofxNetwork\src" />
<Add directory="..\..\..\addons\ofxOpenCv" />
<Add directory="..\..\..\addons\ofxOpenCv\src" />
<Add directory="..\..\..\addons\ofxOpenCv\libs\opencv\include" />
<Add directory="..\..\..\addons\ofxOsc\libs\oscpack\include\ip" />
<Add directory="..\..\..\addons\ofxOsc\libs\oscpack\include\osc" />
<Add directory="..\..\..\addons\ofxOsc\src" />
<Add directory="..\..\..\addons\ofxThread\src" />
<Add directory="..\..\..\addons\ofxVectorMath\src" />
<Add directory="..\..\..\addons\ofxXmlSettings\src" />
<Add directory="..\..\..\addons\ofxXmlSettings\libs" />
<Add directory="..\..\..\addons\ofxVectorGraphics\src" />
<Add directory="..\..\..\addons\ofxVectorGraphics\libs" />
</Compiler>
<Linker>
<Add option="../../../libs/freeImage/FreeImage.lib" />
<Add option="../../../libs/RtAudio/RtAudio.a" />
<Add option="../../../libs/quicktime/Libraries/qtmlClient.lib" />
<Add option="../../../libs/freetype/lib/libfreetype.a" />
<Add option="../../../libs/glut/libglut.a" />
<Add option="../../../libs/videoInput/lib/videoInputLib.a" />
<Add option="../../../libs/fmodex/lib/libfmodex.a" />
<Add option="../../../libs/glee/lib/GLee.lib" />
<Add option="../../../libs/glu/glu32.lib" />
<Add option="../../../addons/ofxOpenCv/libs/opencv/lib/win32/cv.lib" />
<Add option="../../../addons/ofxOpenCv/libs/opencv/lib/win32/cxcore.lib" />
<Add option="..\..\..\addons\ofxOsc\libs\oscpack\lib\win32\oscpack.a" />
<Add option="-lopengl32" />
<Add option="-lglu32" />
<Add option="-ldsound" />
<Add option="-lwinmm" />
<Add option="-ldxguid" />
<Add option="-lstrmbase" />
<Add option="-lstrmiids" />
<Add option="-lz" />
<Add option="-luuid" />
<Add option="-lole32" />
<Add option="-loleaut32" />
<Add option="-lsetupapi" />
<Add option="-lwsock32" />
<Add option="-lws2_32" />
</Linker>
<Unit filename="src\main.cpp">
<Option virtualFolder="src\" />
</Unit>
<Unit filename="src\ofxCvHaarFinder\ofxCvHaarFinder.cpp">
<Option virtualFolder="addons\ofxOpenCV\src\" />
</Unit>
<Unit filename="src\ofxCvHaarFinder\ofxCvHaarFinder.h">
<Option virtualFolder="addons\ofxOpenCV\src\" />
</Unit>
<Unit filename="src\testApp.cpp">
<Option virtualFolder="src\" />
</Unit>
<Unit filename="src\testApp.h">
<Option virtualFolder="src\" />
</Unit>
<Unit filename="..\..\..\addons\ofAddons.h">
<Option virtualFolder="addons\" />
</Unit>
<Unit filename="..\..\..\addons\ofxCvHaarFinder\ofxCvHaarFinder.cpp">
<Option virtualFolder="libs\faceDetection\" />
</Unit>
<Unit filename="..\..\..\addons\ofxCvHaarFinder\ofxCvHaarFinder.h">
<Option virtualFolder="libs\faceDetection\" />
</Unit>
<Unit filename="..\..\..\addons\ofxOpenCv\src\ofxCvBlob.h">
<Option virtualFolder="addons\ofxOpenCV\src\" />
</Unit>
<Unit filename="..\..\..\addons\ofxOpenCv\src\ofxCvColorImage.cpp">
<Option virtualFolder="addons\ofxOpenCV\src\" />
</Unit>
<Unit filename="..\..\..\addons\ofxOpenCv\src\ofxCvColorImage.h">
<Option virtualFolder="addons\ofxOpenCV\src\" />
</Unit>
<Unit filename="..\..\..\addons\ofxOpenCv\src\ofxCvConstants.h">
<Option virtualFolder="addons\ofxOpenCV\src\" />
</Unit>
<Unit filename="..\..\..\addons\ofxOpenCv\src\ofxCvContourFinder.cpp">
<Option virtualFolder="addons\ofxOpenCV\src\" />
</Unit>
<Unit filename="..\..\..\addons\ofxOpenCv\src\ofxCvContourFinder.h">
<Option virtualFolder="addons\ofxOpenCV\src\" />
</Unit>
<Unit filename="..\..\..\addons\ofxOpenCv\src\ofxCvFloatImage.cpp">
<Option virtualFolder="addons\ofxOpenCV\src\" />
</Unit>
<Unit filename="..\..\..\addons\ofxOpenCv\src\ofxCvFloatImage.h">
<Option virtualFolder="addons\ofxOpenCV\src\" />
</Unit>
<Unit filename="..\..\..\addons\ofxOpenCv\src\ofxCvGrayscaleImage.cpp">
<Option virtualFolder="addons\ofxOpenCV\src\" />
</Unit>
<Unit filename="..\..\..\addons\ofxOpenCv\src\ofxCvGrayscaleImage.h">
<Option virtualFolder="addons\ofxOpenCV\src\" />
</Unit>
<Unit filename="..\..\..\addons\ofxOpenCv\src\ofxCvImage.cpp">
<Option virtualFolder="addons\ofxOpenCV\src\" />
</Unit>
<Unit filename="..\..\..\addons\ofxOpenCv\src\ofxCvImage.h">
<Option virtualFolder="addons\ofxOpenCV\src\" />
</Unit>
<Unit filename="..\..\..\addons\ofxOpenCv\src\ofxCvMain.h">
<Option virtualFolder="addons\ofxOpenCV\src\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\app\ofAppGlutGlue.h">
<Option virtualFolder="libs\openframeworks\app\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\app\ofAppRunner.cpp">
<Option virtualFolder="libs\openframeworks\app\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\app\ofAppRunner.h">
<Option virtualFolder="libs\openframeworks\app\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\app\ofSimpleApp.h">
<Option virtualFolder="libs\openframeworks\app\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\communication\ofSerial.cpp">
<Option virtualFolder="libs\openframeworks\communication\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\communication\ofSerial.h">
<Option virtualFolder="libs\openframeworks\communication\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\graphics\ofGraphics.cpp">
<Option virtualFolder="libs\openframeworks\graphics\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\graphics\ofGraphics.h">
<Option virtualFolder="libs\openframeworks\graphics\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\graphics\ofImage.cpp">
<Option virtualFolder="libs\openframeworks\graphics\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\graphics\ofImage.h">
<Option virtualFolder="libs\openframeworks\graphics\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\graphics\ofTexture.cpp">
<Option virtualFolder="libs\openframeworks\graphics\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\graphics\ofTexture.h">
<Option virtualFolder="libs\openframeworks\graphics\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\graphics\ofTrueTypeFont.cpp">
<Option virtualFolder="libs\openframeworks\graphics\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\graphics\ofTrueTypeFont.h">
<Option virtualFolder="libs\openframeworks\graphics\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\ofMain.h">
<Option virtualFolder="libs\openframeworks\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\sound\ofSoundPlayer.cpp">
<Option virtualFolder="libs\openframeworks\sound\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\sound\ofSoundPlayer.h">
<Option virtualFolder="libs\openframeworks\sound\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\sound\ofSoundStream.cpp">
<Option virtualFolder="libs\openframeworks\sound\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\sound\ofSoundStream.h">
<Option virtualFolder="libs\openframeworks\sound\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\utils\ofConstants.h">
<Option virtualFolder="libs\openframeworks\utils\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\utils\ofMath.cpp">
<Option virtualFolder="libs\openframeworks\utils\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\utils\ofMath.h">
<Option virtualFolder="libs\openframeworks\utils\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\utils\ofTypes.h">
<Option virtualFolder="libs\openframeworks\utils\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\utils\ofUtils.cpp">
<Option virtualFolder="libs\openframeworks\utils\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\utils\ofUtils.h">
<Option virtualFolder="libs\openframeworks\utils\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\video\ofQtUtils.cpp">
<Option virtualFolder="libs\openframeworks\video\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\video\ofQtUtils.h">
<Option virtualFolder="libs\openframeworks\video\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\video\ofVideoGrabber.cpp">
<Option virtualFolder="libs\openframeworks\video\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\video\ofVideoGrabber.h">
<Option virtualFolder="libs\openframeworks\video\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\video\ofVideoPlayer.cpp">
<Option virtualFolder="libs\openframeworks\video\" />
</Unit>
<Unit filename="..\..\..\libs\openFrameworks\video\ofVideoPlayer.h">
<Option virtualFolder="libs\openframeworks\video\" />
</Unit>
<Extensions>
<code_completion />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Can't find #include files
« Reply #6 on: December 01, 2008, 02:59:10 pm »
CBP-file in which the file in the path to ofxCvHaarFinder.h is present..
It is not. You need to pass the path to the header file to the compiler using the compiler include path in the project's build options. It's not enough to "tell" C::B only where the header file is. The compiler needs to know, too.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Can't find #include files
« Reply #7 on: December 01, 2008, 03:02:52 pm »
It seems you have many files added twice to your project, one time in a directoy below your projects root dir (e.g. "src\ofxCvHaarFinder\ofxCvHaarFinder.h") and once in a directory outside your projects directory-structure (e.g. "..\..\..\addons\ofxCvHaarFinder\ofxCvHaarFinder.h").

Which one is the right ?

None of your search dirs points to a directory inside your project.

The first thing would be to clean up your project, so that you only use files belonging to it, remove all others, the set up your search dirs correctly to the paths you use, e.g. " src\ofxCvHaarFinder\" if you use "#include ofxCvHaarFinder.h", or just "src" if you use "#include ofxCvHaarFinder\ofxCvHaarFinder.h". If header and source file are in the same directory no search path is needed.

If you need to have files with the same name inside your project, it's not so easy to set it up correctly, so that cpp-files always find the correct headers.

Veremos

  • Guest
Re: Can't find #include files
« Reply #8 on: December 01, 2008, 03:12:33 pm »
Setting the search dir, and some cleaning work indeed, did the job. Thanks a LOT for your quick reply! :D