tags:

views:

241

answers:

3

Using: windows xp, g++ 3.4.4 with cygwin and g++ 3.4.5 with mingw.

I'm compiling a simple unit test class with cppunit.

When I link using g++ 3.4.5 I get a lot of linking errors. When I link with g++ 3.4.4 I don't get any errors and the exe links fine and runs.

I can't seem to trace down the errors, so any thoughts?

Thanks.

EDIT: linking errors: Unreferenced function errors. Like:

 SimpleTest.cpp:(.text+0x313): undefined reference to `CppUnit::Message::Message(std::string const&, std::string const&)'

EDIT: cmd line:

g++ -I g:\projects\thirdparty\cppunit-1.12.1\include -L g:\projects\thirdparty\cppunit-1.12.1\lib -l cppunitd -o main.exe main.cpp SimpleTest.cpp

Update: Same code in Visual Studio: No error, unit test runs as expected.

A: 

As g++ matures, I'm on 4.2.3, it's type checking has gotten more pedantic and for that matter better. With the little information I'd say it's likely that you should look closely at your calls to these methods. I suspect that the types are not quite right. 3.4.4 doesn't catch it, 3.4.5 does. ....JW

Do you have any experience with cppunit? A lot of it is macro driven, so I don't think I'm doing anything weird or special.
cbrulak
This isn't a type problem. The error is a linking error, so compilation (including type-checking) has already succeeded.
Nathan Kitchen
A: 

One thing you could perhaps try is to compile with g++ 3.4.5 and/or 3.4.4 on Linux. If the result then is the same, then it is clearly a property of gcc. Otherwise it more sounds like a mingw issue.

hlovdal
good tip. I suspect it is mingw issue. I find it hard to believe that this simple test case would break on linux.
cbrulak
A: 

Your problem is likely incorrect link line. The order of sources/object files and libraries on the link line matters. Correct link line:

g++ -I g:\projects\thirdparty\cppunit-1.12.1\include \
    -L g:\projects\thirdparty\cppunit-1.12.1\lib \
    -o main.exe main.cpp SimpleTest.cpp -lcppunitd
Employed Russian
no difference. I copied your cmd exactly.
cbrulak