[Q] Unresolved references when linking against the test libs
I apologize in advance if this turns out to be a linker problem not related to boost. So here goes: For compatibility/legacy reasons, we can not use the Boost.Build jamfiles to build our application. Accordingly, I've written a set of traditional makefiles to build the project's executables and have run into difficulties. Specifically, when I try to link my test program against the boost test libraries, I get an error message (reformatted for easy reading) saying that the reference to test_main can not be resolved. Here's the spew (formatted to make it easier to read): g++ -g3 -L../long/debug -L/usr/lib -L/usr/local/lib -L/usr/local/lib/stlport -L/usr/local/lib/boost -o "debug/unit_test" debug/longtest.o -lLong -lboost_unit_test_framework-gcc-mt-p -lboost_test_exec_monitor-gcc-mt-p -lpthread -lc /usr/local/lib/boost/libboost_test_exec_monitor-gcc-mt-p.so: undefined reference to `test_main(int, char**)' collect2: ld returned 1 exit status make: *** [debug/unit_test] Error 1 According to nm, the undefined reference, test_main, is defined in the exec_monitor library. I've tried reordering the libraries but no joy. Any advice and/or hints would be very much appreciated. I am using STLPort-4.6.2 and boost_1_32_0 and Linux (I386) Cheers, Michael
Messagechange the main(..) in your progam to test_main(...)
Robert Ramey
"Michael Peterson"
"Michael Peterson"
wrote in message news:000001c4d401$f2dad520$1d02a8c0@wxp2000... I apologize in advance if this turns out to be a linker problem not related to boost. So here goes: For compatibility/legacy reasons, we can not use the Boost.Build jamfiles to build our application. Accordingly, I've written a set of traditional makefiles to build the project's executables and have run into difficulties.
Specifically, when I try to link my test program against the boost test
MessageHi, Michael Looks like you are trying to use Test Execution Monitor. For documentation check http://www.boost.org/libs/test/doc/components/test_exec_monitor/index.html Specifically look on Usage section, tht answer your question in details. Regards, Gennadiy libraries, I get an error message (reformatted for easy reading) saying that the reference to
test_main can not be resolved. Here's the spew (formatted to make it easier to read):
g++ -g3 -L../long/debug -L/usr/lib -L/usr/local/lib -L/usr/local/lib/stlpor t -L/usr/local/lib/boost
-o "debug/unit_test" debug/longtest.o -lLong -lboost_unit_test_framework-gcc-mt-p
If you are using Test Execution Monitor you dont need to link with above library, only with one below.
-lboost_test_exec_monitor-gcc-mt-p -lpthread -lc
/usr/local/lib/boost/libboost_test_exec_monitor-gcc-mt-p.so: undefined
reference to `test_main(int, char**)' collect2: ld returned 1 exit
status make: *** [debug/unit_test] Error 1 According to nm, the undefined reference, test_main, is defined in the exec_monitor library. I've tried reordering the libraries but no joy. Any advice and/or hints would be very much appreciated.
I am using STLPort-4.6.2 and boost_1_32_0 and Linux (I386)
Cheers,
Michael
"Michael Peterson"
wrote in message news:000001c4d401$f2dad520$1d02a8c0@wxp2000... I apologize in advance if this turns out to be a linker problem not related to boost. So here goes: For compatibility/legacy reasons, we can not use the Boost.Build jamfiles to build our application. Accordingly, I've written a set of traditional makefiles to build the project's executables and have run into difficulties.
Specifically, when I try to link my test program against the boost test
Thanks, Gennadiy and Robert. I may not have provided enough information in my original posting. So, I've attached the code that won't link, i.e., yields the unresolved reference to test main. You'll see that I'm using init_unit_test_suite(). I might add that using test_main() gives rise to the same problem. By the way, this compiles and runs just fine on Windows XP. Sigh... Hope you can help, Cheers, Michael -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Gennadiy Rozental Sent: Saturday, November 27, 2004 10:38 AM To: boost-users@lists.boost.org Subject: [Boost-users] Re: [Q] Unresolved references when linking againstthetest libs MessageHi, Michael Looks like you are trying to use Test Execution Monitor. For documentation check http://www.boost.org/libs/test/doc/components/test_exec_monitor/index.ht ml Specifically look on Usage section, tht answer your question in details. Regards, Gennadiy libraries, I get an error message (reformatted for easy reading) saying that the reference to
test_main can not be resolved. Here's the spew (formatted to make it easier to read):
g++ -g3 -L../long/debug -L/usr/lib -L/usr/local/lib g++ -L/usr/local/lib/stlpor t -L/usr/local/lib/boost
-o "debug/unit_test" debug/longtest.o -lLong -lboost_unit_test_framework-gcc-mt-p
If you are using Test Execution Monitor you dont need to link with above library, only with one below.
-lboost_test_exec_monitor-gcc-mt-p -lpthread -lc
/usr/local/lib/boost/libboost_test_exec_monitor-gcc-mt-p.so: undefined
reference to `test_main(int, char**)' collect2: ld returned 1 exit
status make: *** [debug/unit_test] Error 1 According to nm, the undefined reference, test_main, is defined in the exec_monitor library. I've tried reordering the libraries but no joy. Any advice and/or hints would be very much appreciated.
I am using STLPort-4.6.2 and boost_1_32_0 and Linux (I386)
Cheers,
Michael
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
"Michael Peterson"
Thanks, Gennadiy and Robert. I may not have provided enough information in my original posting. So, I've attached the code that won't link, i.e., yields the unresolved reference to test main. You'll see that I'm using init_unit_test_suite(). I might add that using test_main() gives rise to the same problem.
The problem is that you are trying to link both with Unit Test Framework and Test Execution Monitor, while you only need only one of them. If you are using init_unit_test_suite you need to link with former, while if are using test_main you need to link with later.
By the way, this compiles and runs just fine on Windows XP. Sigh...
Both components supply main function. This linker select one that refer to init_unit_test_suite.
Hope you can help,
Cheers,
Michael
HTH, Gennadiy
participants (3)
-
Gennadiy Rozental
-
Michael Peterson
-
Robert Ramey