Author Topic: C::B not finding cppunit headers with custom makefile  (Read 5884 times)

Offline criesbeck

  • Multiple posting newcomer
  • *
  • Posts: 10
C::B not finding cppunit headers with custom makefile
« on: March 02, 2009, 09:36:25 pm »
I'm trying to use a custom makefile with Cygwin in Code::Blocks. C::B seems to be running the makefile correctly, but the compile command fails. The same command works fine pasted into a Cygwin window. What am I missing?

Latest Cygwin (1.5.25-15)
g++ with cppunit installed in the default /lib and /usr/include directories
Code::Blocks 8.02.
Cygwin GCC is the default compiler
Nothing has been added to search directories for compiler or project.

My project directory has a two .cpp, one .h file (examples from CppUnit site), a Makefile, and the C::B .cbp file.

My project has custom makefile checked and one target, all. The Make clean command is "$make -f $makefile clean" The build command is "$make -f $makefile $target". I set the build output to Full command line.

Build | Clean works fine.

Build | Build runs the correct compile commands, but g++ doesn't find the CppUnit header files. Pasting the command shown in the Build log works fine in the Cygwin console window.

Here's the Build Log:

g++ -c -g -Wall ExampleTestCase.cpp -o ExampleTestCase.o
ExampleTestCase.cpp:1:41: error: cppunit/config/SourcePrefix.h: No such file or directory
In file included from ExampleTestCase.cpp:2:
ExampleTestCase.h:5:45: error: cppunit/extensions/HelperMacros.h: No such file or directory
In file included from ExampleTestCase.cpp:2:
ExampleTestCase.h:13: error: 'CPPUNIT_NS' has not been declared
ExampleTestCase.h:13: error: expected `{' before 'TestFixture'
...
make: *** [ExampleTestCase.o] Error 1
Process terminated with status 2 (0 minutes, 0 seconds)
16 errors, 0 warnings

 
If I copy and paste that first line, "g++ -c -g -Wall ExampleTestCase.cpp -o ExampleTestCase.o", into the Cygwin console when I'm in the project directory, the compilation succeeds.

Ideas on what to try next? More info I should post here? I've done lots of searching under the makefile topic -- but perhaps that's not the issue?

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: C::B not finding cppunit headers with custom makefile
« Reply #1 on: March 02, 2009, 10:12:21 pm »
Did you follow the steps in the wiki ?

http://wiki.codeblocks.org/index.php?title=Installing_Cygwin_Compiler

I use MinGW in windows and not cygwin, so I can not guarantee that it works, but you should give it a try.

Offline criesbeck

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: C::B not finding cppunit headers with custom makefile
« Reply #2 on: March 02, 2009, 10:46:57 pm »
I hadn't, since I'd started with Cygwin on the C::B initial install and compiler-detect, but I tried and it didn't help.

But I now know the problem but not the cause or the fix. I stuck in a "g++ --version" on my "clean" target and it says it's running g++.exe (4.3.2-tdm-2 mingw32) 4.3.2. In Cygwin, it's g++ (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125).

BUT where is it being set to use MinGW? I never told it to use it, and both Cygwin compilers settings have C:\Coding\cygwin (which is correct) for Compiler's Installation Directory. I can't find MinGW in any setting anywhere. Is there some configuration file or registry to check?

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: C::B not finding cppunit headers with custom makefile
« Reply #3 on: March 02, 2009, 10:58:26 pm »
If you use 8.02 (as you posted) make sure the path to the cygwin-compiler is before the path to the MinGW-compiler.
This release looks in systems search-path before it looks in the master-path.

This issue is fixed in recent versions.

If that leads to problems, because you have projects that use two different compilers with executables that are named equal, you should think about using a recent nightly-build.

Offline criesbeck

  • Multiple posting newcomer
  • *
  • Posts: 10
[SOLVED] Re: C::B not finding cppunit headers with custom makefile
« Reply #4 on: March 02, 2009, 11:20:09 pm »
That was it. Cygwin was on my user PATH variable , and MinGW was on the system PATH variable.

Thanks