[pkg-boost-devel] Bug#456863: Boost.Test: main() not defined in shared library

Jens Seidel jensseidel at users.sf.net
Tue Dec 18 08:59:34 UTC 2007


Package: libboost-test1.34.1
Version: 1.34.1-2
Severity: important

Hi,

the unit test library of Boost is currently not usable if one wants to
link against a shared library instead of using header files or the
static library.

Trying to link the sample program from
http://www.boost.org/libs/test/doc/components/utf/index.html

#include <boost/test/unit_test.hpp>

void my_test_function() { }

boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[])
{
  boost::unit_test::test_suite* test = BOOST_TEST_SUITE("Master test suite");
  test->add( BOOST_TEST_CASE( &my_test_function ) );
  return test;
}

results in:
$ g++ -Wall test.cpp -lboost_unit_test_framework-gcc41-1_34_1
/usr/lib/gcc/i486-linux-gnu/4.2.3/../../../../lib/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status

Linking against the static library works:
$ g++ -Wall test.cpp /usr/lib/libboost_unit_test_framework-gcc41-1_34_1.a 
$ ./a.out 
Running 1 test case...

*** No errors detected


Jens





More information about the pkg-boost-devel mailing list