Boost logo

Boost :

From: Douglas Gregor (doug.gregor_at_[hidden])
Date: 2007-05-15 02:07:49


I'm having trouble getting programs using boost_unit_test_framework
to link. The fundamental issue is that trying to link something like
this:

        g++ -fPIC -o algorithms_test algorithms_test.o -
lboost_unit_test_framework

dies with a linker error:

   /usr/bin/ld: Undefined symbols:
   _main
   collect2: ld returned 1 exit status

The issue, of course, is that "main" lives within the library
boost_unit_test_framework, but linkers don't look into libraries
(either static or dynamic) to find main. I suspect this is also the
reason for the FAQ item on the test library page (http://
www.boost.org/libs/test/doc/faq.html#Item_9), which says that Boost
Test components cannot be compiled as DLL, but perhaps there are
other issues there.

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

For some reason, this non-standard practice seems to work... but I
can't imagine it's truly portable, and it forces users of
boost_unit_test_framework into statically linking in a non-
traditional way.

Why must main() be in a library? It seems a trivial matter to fix.

        - Doug


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk