Re: [Boost-users] [Test]: Problem with simple Boost.Test

Date: Mon, 17 Jun 2013 23:03:16 +0000 (UTC) From: legalize+jeeves@mail.xmission.com<mailto:legalize+jeeves@mail.xmission.com> (Richard) To: boost-users@lists.boost.org<mailto:boost-users@lists.boost.org> Subject: Re: [Boost-users] [Test]: Problem with simple Boost.Test Message-ID: <kpo4jk$2ih$2@ger.gmane.org<mailto:kpo4jk$2ih$2@ger.gmane.org>> [Please do not mail me a copy of your followup] boost-users@lists.boost.org<mailto:boost-users@lists.boost.org> spake the secret code <7364AB234369D348AE1CEBC1A86132DBAD32EA@SVLITMX02.shoretel.com<http://SVLITMX02.shoretel.com>> thusly: $ ${CXX} -c --std=c++0x -g -I${TARGET}/include cma.cpp -o cma.o $ ${CXX} --std=c++0x -g cma.o ${TARGET}/lib/libboost_test_exec_monitor.a \ ${TARGET}/lib/libboost_unit_test_framework.dylib -o cma Why are you linking against boost_test_exec_monitor? I've never needed to do that. boost_unit_test_framework should be enough. Interesting. Because I'm finding the following: $ ${CXX} -c --std=c++0x -g -I${TARGET}/include cma.cpp -o cma.o $ ${CXX} --std=c++0x -g cma.o ${TARGET}/lib/libboost_unit_test_framework.dylib -o cma Undefined symbols for architecture x86_64: "_main", referenced from: implicit entry/start for main executable ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status $ But that is also what I'm finding with the system GCC and the Fink install of Boost 1.46, and so that behavior isn't unique my attempt to build/use a Boost with GCC 4.8.0 using --std=c++0x. $ g++ -c -g -I/sw/include cma.cpp -o cma.o $ g++ -g -L/sw/lib cma.o -lboost_unit_test_framework-mt Undefined symbols for architecture x86_64: "_main", referenced from: start in crt1.10.6.o ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status $ g++ --version i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) Copyright (C) 2007 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ fink list --tab boost1.46 Information about 7237 packages read in 1 seconds. i boost1.46.1.cmake 1.46.1-2 Boost C++ Libraries i boost1.46.1.cmake-shlibs 1.46.1-2 Boost C++ Libraries $ ________________________________ This e-mail and any attachments are confidential. If it is not intended for you, please notify the sender, and please erase and ignore the contents.

thusly:$ ${CXX} -c --std=c++0x -g -I${TARGET}/include cma.cpp -o cma.o
$ ${CXX} --std=c++0x -g cma.o ${TARGET}/lib/libboost_test_exec_monitor.a \ ${TARGET}/lib/libboost_unit_test_framework.dylib -o cma
Why are you linking against boost_test_exec_monitor? I've never needed to do that. boost_unit_test_framework should be enough.
Interesting. Because I'm finding the following:
I know docs are not ideal but this part is very clear I thought. test_exec_monitor is an old alternative t ounit test framework, which is long deprecated and they definitely do not require each other
$ ${CXX} -c --std=c++0x -g -I${TARGET}/include cma.cpp -o cma.o $ ${CXX} --std=c++0x -g cma.o
${TARGET}/lib/libboost_unit_test_framework.dylib -o cma
Undefined symbols for architecture x86_64: "_main", referenced from: implicit entry/start for main executable ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status $
How do you use Boost.Test? Automated test unit registration? Are you sure you've defined BOOST_TEST_MODULE/BOOST_TEST_MAIN? Gennadiy

[Please do not mail me a copy of your followup] I wrote:
Why are you linking against boost_test_exec_monitor?
I've never needed to do that. boost_unit_test_framework should be enough.
boost-users@lists.boost.org spake the secret code <7364AB234369D348AE1CEBC1A86132DBAD4B95@SVLITMX02.shoretel.com> thusly:
Interesting. Because I'm finding the following:
$ ${CXX} -c --std=c++0x -g -I${TARGET}/include cma.cpp -o cma.o $ ${CXX} --std=c++0x -g cma.o ${TARGET}/lib/libboost_unit_test_framework.dylib -o cma Undefined symbols for architecture x86_64: "_main", referenced from: implicit entry/start for main executable ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status $
There are several ways you can get an appropriate implementation of main() from Boost.Test. Since you are using the dynamic library version of Boost.Test, you need at most one source file that defines BOOST_TEST_MAIN before including <boost/test/unit_test.hpp>. (You should also be defining BOOST_TEST_DYN_LINK before including unit_test.hpp in all your source files since you are using the dynamically linked library.) -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Computer Graphics Museum <http://computergraphicsmuseum.org> The Terminals Wiki <http://terminals.classiccmp.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
participants (3)
-
Damien Kick
-
Gennadiy Rozental
-
legalize+jeeves@mail.xmission.com