Undefined reference to 'main' with Boost Test. Why?

Why in the heck did the boost unit test framework change to remove main?
Why does the documentation not reflect this? Why are the example
describing the old behavior? How am I now suppose to use the Boost unit
test framework?
The following program will NOT compile because of the change in 1.34.1
since the 1.33:
/* test_grnn.cpp
#include

Stephen Torri
Why in the heck did the boost unit test framework change to remove main?
Shared lib version of Boost.Test does not include main for portability reasons. You can search for very long discussion on this topic in the mailing list.
Why does the documentation not reflect this? Why are the example describing the old behavior? How am I now suppose to use the Boost unit test framework?
Enforce linking with static library in your command line.
The following program will NOT compile because of the change in 1.34.1 since the 1.33:
/* test_grnn.cpp
#include
using namespace boost::unit_test_framework;
void test_distance_squared () { // do work }
test_suite* init_unit_test_suite ( int, char** ) { test_suite* test = BOOST_TEST_SUITE ("GRNN test suite");
// Allow GRNN to allocate our memory at any location test->add ( BOOST_TEST_CASE ( &test_distance_squared ) );
return test; }
Alternatively you can write above test module as: #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE GRNN test suite BOOST_AUTO_TEST_CASE( test_distance_squared ) { .... } and it will work with shared lib. Remove define BOOST_TEST_DYN_LINK and it will work with static lib as well. Gennadiy

On Tue, 2008-03-11 at 19:09 +0000, Gennadiy Rozental wrote:
#define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE GRNN test suite
BOOST_AUTO_TEST_CASE( test_distance_squared ) { .... }
and it will work with shared lib. Remove define BOOST_TEST_DYN_LINK and it will work with static lib as well.
Gennadiy
What I want to know is how I can create a layered test suite like is eluded to by the documentation? The documentation does not provide any examples of a test suite within a test suite. I can change my test program to follow the above format since its is quite simple. Stephen

Stephen Torri
On Tue, 2008-03-11 at 19:09 +0000, Gennadiy Rozental wrote:
#define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE GRNN test suite
BOOST_AUTO_TEST_CASE( test_distance_squared ) { .... }
and it will work with shared lib. Remove define BOOST_TEST_DYN_LINK and it will work with static lib as well.
Gennadiy
What I want to know is how I can create a layered test suite like is eluded to by the documentation? The documentation does not provide any examples of a test suite within a test suite.
It's covered in docs. You can use BOOST_AUTO_TEST_SUITE. There is an example of coplex hierarhy there as well. In general it's as simple as: BOOST_AUTO_TEST_SUITE(s1) BOOST_AUTO_TEST_CASE(test1) { } BOOST_AUTO_TEST_SUITE(internal_suite) BOOST_AUTO_TEST_CASE(test1) { } BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE(s2) BOOST_AUTO_TEST_CASE(test1) { } BOOST_AUTO_TEST_SUITE_END() Gennadiy

On Tue, 2008-03-11 at 21:20 +0000, Gennadiy Rozental wrote:
It's covered in docs. You can use BOOST_AUTO_TEST_SUITE. There is an example of coplex hierarhy there as well. In general it's as simple as:
BOOST_AUTO_TEST_SUITE(s1)
BOOST_AUTO_TEST_CASE(test1) { }
BOOST_AUTO_TEST_SUITE(internal_suite)
BOOST_AUTO_TEST_CASE(test1) { }
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE(s2)
BOOST_AUTO_TEST_CASE(test1) { }
BOOST_AUTO_TEST_SUITE_END()
Gennadiy
I appreciate the example. Thanks. Stephen

Here is my updated test program. The compiler still complains about the
undefined reference to main.
-----------------------
Compile results
/bin/bash ../../../../libtool --tag=CXX --mode=link g++ -g -O2 -Werror -DNO_LIBREVERSE_DEBUG -static -o test_grnn test_grnn-test_grnn.o \
-L../../../../libreverse -lreverse -lboost_date_time -lboost_unit_test_framework
g++ -g -O2 -Werror -DNO_LIBREVERSE_DEBUG -o test_grnn test_grnn-test_grnn.o -L/home/storri/src/libreverse/libreverse /home/storri/src/libre\
verse/libreverse/.libs/libreverse.a -L/Libs -L/lib -licui18n /usr/lib/libexpat.so -lboost_filesystem -lgcov -lboost_date_time -lboost_unit_t\
est_framework
/usr/lib/gcc/i486-linux-gnu/4.1.3/../../../../lib/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
make[1]: *** [test_grnn] Error 1
make[1]: Leaving directory `/home/storri/src/libreverse/libreverse/components/input/grnn'
make: *** [check-am] Error 2
-----------------------
#include

Stephen Torri
Here is my updated test program. The compiler still complains about the undefined reference to main.
// Boost Test declaration and Checking macro #include
#include
You should #include
participants (2)
-
Gennadiy Rozental
-
Stephen Torri