Code::Blocks Forums

User forums => Help => Topic started by: criesbeck on March 03, 2009, 12:14:25 am

Title: C::B ignoring final build step in custom makefile?
Post by: criesbeck on March 03, 2009, 12:14:25 am
A very different problem (I think) than my previous one.

Using C::B 8.02 with Cygwin with a custom makefile. The project has one target "all". When I do build, the compile steps are correct, but the final linking step that fails is NOT what my makefile has. Running make in Cygwin (even in the Windows command shell) does the right thing. I can manually add library switches in C::B, but that removes the point of the makefile.

This is the Build Log that results in C::B. The makefile is below that. The first two commands ("g++ ...") are from my makefile. The third command (line 5, ""g++.exe  -o main.exe ...") is not. I deliberately changed my makefile to say gcc, which is ignored, as are the LDFLAG and LIB variables.

Ideas?


-------------- Build: all in testapp ---------------

g++.exe -Wall -g -fexceptions  -O2     -c C:/NU/courses/cs211/projects/testapp/Main.cpp -o C:/NU/courses/cs211/projects/testapp/.objs/Main.o
g++.exe -Wall -g -fexceptions  -O2     -c C:/NU/courses/cs211/projects/testapp/ExampleTestCase.cpp -o C:/NU/courses/cs211/projects/testapp/.objs/ExampleTestCase.o
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_uninitialized.h: In static member function `static void ExampleTestCase::addTestsToSuite(CppUnit::TestSuiteBuilderContextBase&)':
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_uninitialized.h:82: warning: '__cur' might be used uninitialized in this function
g++.exe  -o main.exe C:/NU/courses/cs211/projects/testapp/.objs/Main.o C:/NU/courses/cs211/projects/testapp/.objs/ExampleTestCase.o   
C:/NU/courses/cs211/projects/testapp/.objs/Main.o: In function `main':
C:/NU/courses/cs211/projects/testapp/Main.cpp:13: undefined reference to `CppUnit::TestResult::TestResult(CppUnit::SynchronizedObject::SynchronizationObject*)'
C:/NU/courses/cs211/projects/testapp/Main.cpp:16: undefined reference to `CppUnit::TestResultCollector::TestResultCollector(CppUnit::SynchronizedObject::SynchronizationObject*)'
...


Makefile:

SRCS = ExampleTestCase.cpp Main.cpp
HDRS = ExampleTestCase.h
HANDIN = handin
CC = g++
OBJS = $(SRCS:.cpp=.o)
APP = main.exe
CFLAGS = -c -g -Wall
LDFLAGS = -L/opt/local/lib
LIBS = -lcppunit -ldl

all: $(OBJS)
   gcc $(LDFLAGS) $(OBJS) -o $@ $(LIBS)

# Recompile everything with header files change
%.o: %.cpp $(INCS)
   $(CC) $(CFLAGS) $< -o $@

handin:
   zip handin.zip Makefile *.cpp *.h *.txt

clean:
   -rm $(APP) *.o
Title: Re: C::B ignoring final build step in custom makefile?
Post by: Jenna on March 03, 2009, 07:29:48 am
Ideas?

Try a recent nighly build, they work out of the box, are (normally) stable and have some issues fixed.

The using of custom makefiles has improved a lot since 8.02-release.

EDIT:
I did not read carefully.
It seems your makefile is ignored completely.
Do you have it in the projects root-directory ?
Do you really have checked the "This is a custom makefile" box in the projects properties ?
Title: Re: C::B ignoring final build step in custom makefile?
Post by: criesbeck on March 03, 2009, 04:25:40 pm
You're right - the Makefile is being ignored. I missed that because the Makefile was being used when I had the previous problem with MinGW being used instead of Cygwin (documented in "C::B not finding cppunit headers with custom makefile").

But I'm still puzzled why the makefile is being ignored.  "custom makefile" is definitely checked. The projects CBP file has makefile_is_custom = 1 and the right target "all". Makefile is in the top-level project directory and running make there in a Cygwin or even Windows Command shell works fine.

I've copied the Project XML from .cbp file in case anything obvious shows.

I'll create a new project yet again, and try the nightly build. The latter may be an issue because I was intending to have students in an introductory C++ course use C::B and there's only so much I can throw at them in week 1.

 <Project>
      <Option title="testapp" />
      <Option makefile_is_custom="1" />
      <Option pch_mode="2" />
      <Option compiler="cygwin" />
      <MakeCommands>
         <Build command="$make -f $makefile $target" />
         <CompileFile command="$make -f $makefile $file" />
         <Clean command="$make -f $makefile clean" />
         <DistClean command="$make -f $makefile distclean$target" />
      </MakeCommands>
      <Build>
         <Target title="all">
            <Option output="main" prefix_auto="1" extension_auto="1" />
            <Option working_dir="..\testapp" />
            <Option object_output="C:\NU\courses\cs211\projects\testapp\.objs" />
            <Option type="1" />
            <Option compiler="cygwin" />
            <Option use_console_runner="0" />
            <Compiler>
               <Add option="-O2" />
            </Compiler>
            <MakeCommands>
               <Build command="$make -f $makefile $target" />
               <CompileFile command="$make -f $makefile $file" />
               <Clean command="$make -f $makefile clean" />
               <DistClean command="$make -f $makefile distclean$target" />
            </MakeCommands>
         </Target>
      </Build>
      <Compiler>
         <Add option="-Wall" />
         <Add option="-g" />
         <Add option="-fexceptions" />
      </Compiler>
      <Unit filename="ExampleTestCase.cpp" />
      <Unit filename="ExampleTestCase.h" />
      <Unit filename="Main.cpp" />
      <Unit filename="Makefile" />
      <Extensions>
         <code_completion />
         <debugger />
      </Extensions>
   </Project>
</CodeBlocks_project_file>


Title: [SOLVED?] Re: C::B ignoring final build step in custom makefile?
Post by: criesbeck on March 03, 2009, 05:00:15 pm
I deleted the .cbp project file, restarted C::B, tried creating the project again, and this time things seem to work.

I can't find a difference between the old project that ignored the Makefile and the new one that uses it, which makes me nervous for future problems, but at least I can get back to work.

Thanks, everyone.