g++ resolves linker errors based on the order the libraries, source files, and object files appear on the command line. Unfortunately, it will produce errors like this if things are not quite in the "right" order. You should try putting "-lcppunit" at the front of any other sources that are used during linking.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
you could try to link statically against libcppunit, i.e.: instead of -lcppunit add /usr/lib/libcppunit.a to your Linker Line.
Another Question: could it be that libcppunit is compiled with a different compiler than the one you're using now (e.g. g++ >= 3.0)? g++ did change it's namemangling at least once in the last couple of years ...
Cheers
Max
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It looks like unittest.o is the first thing that is linked. I'd try putting -lcppunit even before the object file. I'm not saying it will work, but it's my best guess at the moment.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
When I try to link my unittests I get a huge amount of linker errors:
g++ -Wl,-rpath,/opt/qt/x86/qt3/lib -o unittest unittest.o -L/opt/qt/x86/qt3/lib -L/usr/X11R6/lib -lcppunit -lqt-mt -lXext -lX11 -lm
unittest.o(.text+0x16): In function `main':
: undefined reference to `CppUnit::TextUi::TestRunner::TestRunner(CppUnit::Outputter *)'
many like this one follow.
I have no idea what could be wrong. Seems like g++ ignores the library.
>g++ --version
2.95.3
>ls /usr/lib/libcppunit*
/usr/lib/libcppunit-1.8.so.0 /usr/lib/libcppunit.la
/usr/lib/libcppunit-1.8.so.0.0.0 /usr/lib/libcppunit.so
/usr/lib/libcppunit.a
Could anyone help me ?
g++ resolves linker errors based on the order the libraries, source files, and object files appear on the command line. Unfortunately, it will produce errors like this if things are not quite in the "right" order. You should try putting "-lcppunit" at the front of any other sources that are used during linking.
Thanks for your help, but if you look at the g++ line in my post:
g++ -Wl,-rpath,/opt/qt/x86/qt3/lib -o unittest unittest.o -L/opt/qt/x86/qt3/lib -L/usr/X11R6/lib -lcppunit -lqt-mt -lXext -lX11 -lm
-lcppunit is the first library that is linked. I even tried
g++ -lcppunit ...
without success...
strange.
Any other suggestions ?
Hi,
you could try to link statically against libcppunit, i.e.: instead of -lcppunit add /usr/lib/libcppunit.a to your Linker Line.
Another Question: could it be that libcppunit is compiled with a different compiler than the one you're using now (e.g. g++ >= 3.0)? g++ did change it's namemangling at least once in the last couple of years ...
Cheers
Max
It looks like unittest.o is the first thing that is linked. I'd try putting -lcppunit even before the object file. I'm not saying it will work, but it's my best guess at the moment.
It could be that my cppunit is compiled with gcc 3.x. I installed a rpm package for cppunit and am not sure. How can I find it out ?
But this takes me to my next problem: I can't compile cppunit with gcc 2.95.3. See my newest post for this...
Thank you for your help,
Markus