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

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

dies with a linker error:

   /usr/bin/ld: Undefined symbols:
   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://, 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

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, gregod at, cpdaniel at, john at