
Hi ! An'n Dingsdag 15 Mai 2007 hett Vladimir Prus schreven:
Douglas Gregor wrote:
Our tests pass because BBv2 decides to put the archive file on the link line:
g++ -fPIC -o algorithms_test algorithms_test.o libboost_unit_test_framework.a
No, it uses the static library, which has _main.
Further, in my testing putting 'main' in static library works. I believe that even works on Windows. Furthermore, previous testing reveals that on Linux, putting 'main' in shared library works as well.
Correct.
Why must main() be in a library? It seems a trivial matter to fix. The real issue is that there's no 'main()' in library, as shown below:
ghost@wind:~/Work/Boost/boost-rc/stage/lib$ readelf --symbols libboost_unit_test_framework-gcc40-d.so | grep main 871: 00074a43 17 OBJECT WEAK DEFAULT 12 _ZTSSt12domain_error 1253: 0007ed68 12 OBJECT WEAK DEFAULT 22 _ZTISt12domain_error 165: 00000000 0 FILE LOCAL DEFAULT ABS unit_test_main.cpp 259: 0007ed98 4 OBJECT LOCAL HIDDEN 22 DW.ref._ZTISt12domain_err 1128: 00074a43 17 OBJECT WEAK DEFAULT 12 _ZTSSt12domain_error 1510: 0007ed68 12 OBJECT WEAK DEFAULT 22 _ZTISt12domain_error
When both static and shared libraries are present, gcc picks shared on most platforms of note. Since shared library lacks 'main', you get linker error.
Right.
I believe this is intentional change made in Boost.Test for 1.34, in the interest of making Linux (where 'main' can be in shared library) and Windows (where 'main' cannot be in shared library), uniform.
Yes, that was the intention
However, you'd need to ask Gennadiy how to your tests work now.
Just #define BOOST_TEST_DYN_LINK The autotest code then creates a main for you. Taking a look at libs/test/build/Jamfile.v2 reveals : usage-requirements <define>BOOST_TEST_NO_AUTO_LINK=1 <link>shared:<define>BOOST_TEST_DYN_LINK=1 which Boost.Build applies automagically ;-)) Yours, Jürgen -- * Dipl.-Math. Jürgen Hunold ! Ingenieurgesellschaft für * voice: ++49 511 262926 57 ! Verkehrs- und Eisenbahnwesen mbH * fax : ++49 511 262926 99 ! Lister Straße 15 * juergen.hunold@ivembh.de ! www.ivembh.de * * Geschäftsführer: ! Sitz des Unternehmens: Hannover * Prof. Dr.-Ing. Thomas Siefer ! Amtsgericht Hannover, HRB 56965 * PD Dr.-Ing. Alfons Radtke !