Boost.Test linker error - undefined reference to 'main'
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
boost (Ubuntu) |
Invalid
|
Undecided
|
Unassigned |
Bug Description
I get the following error while linking with libboost_
user23@
/usr/lib/
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
I am using this example http://
But, it works fine while linking with the static library using the following command.
g++ test3.cpp /usr/lib/
unit_test_
// Boost.Test
#include <boost/
using boost::
// most frequently you implement test cases as a free functions
void free_test_
{
// reports 'error in "free_test_
BOOST_CHECK(2 == 1); // non-critical test => continue after failure
int* p = (int*)0;
*p = 0;
}
test_suite*
init_unit_
test_suite* test= BOOST_TEST_SUITE( "Unit test example 1" );
// this example will pass cause we know ahead of time number of expected failures
test->add( BOOST_TEST_CASE( &free_test_function ), 1 /* expected one error */ );
return test;
}
// EOF
Changed in boost: | |
status: | New → Invalid |
The boost documentation is outdated. Please read include/ boost/test/ unit_test. hpp BOOST_TEST_ DYN_LINK) && defined( BOOST_TEST_ MAIN)
/usr/
which defines "main" (i.e. it is not a real symbol in the lib*.so).
You will find the requirement for two precompiler defines
if defined(
Note: earlier boost libraries did not require those defines,
and I did only came across this as ALL my programs did
not compile anymore after upgrading the operating system.
(actually to Ubuntu 08.04 w/ boost 1.34.1).
However, blame the boost developers, not the packagers.