Josh wrote:
I have a very simple program ******************************************************************** #include <iostream> #include
using boost::unit_test::test_suite; void MyTest() { BOOST_CHECK(2==2); }
test_suite * init_unit_test_suite( int, char* [] ) { test_suite* test= BOOST_TEST_SUITE( "Simple test" ); test->add(BOOST_TEST_CASE( &MyTest ), 0); return test; } **************************************************************************************** I am trying to compile it using the following commands
g++ -c BoostTest.cpp -I~/boost/include/boost-1_33_1/ g++ -o BT BoostTest.o -I/home/josh/boost/include/boost-1_33_1/ /home/josh/boost/lib/libboost_unit_test_framework-gcc-s.a
The first step completes without a problem, the linking stage gives the following errors
BoostTest.o(.text+0x15b): In function `MyTest()': : undefined reference to `boost::test_tools::tt_detail::test_and_continue_impl(bool, boost::basic_wrap_stringstream<char>&, boost::unit_test::basic_cstring<char const>, unsigned int, bool, boost::unit_test::log_level)' BoostTest.o(.text+0x258): In function `init_unit_test_suite(int, char**)': : undefined reference to `boost::unit_test::test_suite::add(boost::unit_test::test_case*, unsigned long, int)' BoostTest.o(.gnu.linkonce.t._ZN5boost9unit_test16create_test_caseEPFvvESs+0x12): In function `boost::unit_test::create_test_case(void (*)(), std::basic_string
)': : undefined reference to `boost::unit_test::ut_detail::normalize_test_case_name(std::basic_string &)' BoostTest.o(.gnu.linkonce.t._ZN5boost9unit_test18function_test_caseC1EPFvvENS0_13basic_cstringIKcEE+0x1b): In function `boost::unit_test::function_test_case::function_test_case(void (*)(), boost::unit_test::basic_cstring<char const>)': : undefined reference to `boost::unit_test::test_case::test_case(boost::unit_test::basic_cstring<char const>, bool, unsigned long, bool)' BoostTest.o(.gnu.linkonce.r._ZTVN5boost9unit_test18function_test_caseE+0x10): undefined reference to `boost::unit_test::test_case::size() const' BoostTest.o(.gnu.linkonce.t._ZN5boost9unit_test9test_caseD2Ev+0xc): In function `boost::unit_test::test_case::~test_case()': : undefined reference to `vtable for boost::unit_test::test_case' BoostTest.o(.gnu.linkonce.r._ZTIN5boost9unit_test18function_test_caseE+0x8): undefined reference to `typeinfo for boost::unit_test::test_case' *************************************************************
PLEASE HELP! Josh
I just had a very similar problem. I have been using the library fine under Visual Studio, and I am trying to test my code on Linux now. Any help would be greatly appreciated. Thanks, Ed g++ (GCC) 4.1.1 20060525 (Red Hat 4.1.1-1) Fedora 5 [root@localhost src]# make check Making check in . make[1]: Entering directory `/root/Desktop/hivm_svn_test/trunk/src' make testhivm make[2]: Entering directory `/root/Desktop/hivm_svn_test/trunk/src' g++ -g -O2 -o testhivm BioProcessor.o Client.o CrossValidationExperiment.o ExperimentAnalyzer.o ExperimentResult.o FileIO.o FunctionObjects.o LibSvmAdapter.o Log.o Options.o PreProcWorkUnit.o PreProcessor.o SelfTestExperiment.o SvmMachine.o SvmWorkUnit.o ValidationExperiment.o dpl.o svm.o ./3rd_party/boost/lib/* -L./3rd_party/boost/lib/libboost_unit_test_framework-gcc-mt-d-1_33_1.a make[2]: Leaving directory `/root/Desktop/hivm_svn_test/trunk/src' make[1]: Leaving directory `/root/Desktop/hivm_svn_test/trunk/src' ./3rd_party/boost/lib/libboost_unit_test_framework-gcc-mt-d-1_33_1.a(framework.o): In function `boost::unit_test::framework::init(int, char**)': /root/Desktop/boost_1_33_1/boost/test/impl/framework.ipp:192: undefined reference to `init_unit_test_suite(int, char**)' collect2: ld returned 1 exit status make[2]: *** [testhivm] Error 1 make[1]: *** [check-am] Error 2 make: *** [check-recursive] Error 1