Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am novice to ubuntu and Boost. I have installed ubuntu 11.10 and followed the instructions from the website (http://www.alittlemadness.com/2009/03/31/c-unit-testing-with-boosttest/) to try BOOST unit test. I install the boost library, and copy the code as in part 3 and try to execute it but i have errors while executing.

8w6Wa.o: In function `init_unit_test()':
bTest.cpp:(.text+0x51): undefined reference to
`boost::unit_test::framework::master_test_suite()'
/tmp/ccZ8w6Wa.o: In function `main':
bTest.cpp:(.text+0x9f): undefined reference to
`boost::unit_test::unit_test_main(bool (*)(), int, char**)'
/tmp/ccZ8w6Wa.o: In function `universeInOrder::test_method()':
bTest.cpp:(.text+0x121): undefined reference to
`boost::unit_test::unit_test_log_t::set_checkpoint(boost::unit_test::basic_cstring<char
const>, unsigned int, boost::unit_test::basic_cstring<char const>)'
bTest.cpp:(.text+0x1e3): undefined reference to
`boost::test_tools::tt_detail::check_impl(boost::test_tools::predicate_result
const&, boost::unit_test::lazy_ostream const&, boost::unit_test::basic_cstring<char
const>, unsigned int, boost::test_tools::tt_detail::tool_level,
boost::test_tools::tt_detail::check_type, unsigned int, ...)'
/tmp/ccZ8w6Wa.o: In function `__static_initialization_and_destruction_0(int, int)':
bTest.cpp:(.text+0x2ea): undefined reference to
`boost::unit_test::ut_detail::auto_test_unit_registrar::auto_test_unit_registrar(boost::unit_test::test_case*,
unsigned long)'
/tmp/ccZ8w6Wa.o: In function `boost::unit_test::unit_test_log_t::unit_test_log_t()':
bTest.cpp:(.text._ZN5boost9unit_test15unit_test_log_tC2Ev[_ZN5boost9unit_test15unit_test_log_tC5Ev]+0x21):
undefined reference to `vtable for boost::unit_test::unit_test_log_t'
/tmp/ccZ8w6Wa.o: In function
`boost::unit_test::make_test_case(boost::unit_test::callback0<boost::unit_test::ut_detail::unused>
c    onst&, boost::unit_test::basic_cstring<char const>)':
bTest.cpp:(.text._ZN5boost9unit_test14make_test_caseERKNS0_9callback0INS0_9ut_detail6unusedEEENS0_13basic_cstringIKcEE[boost::unit_test::make_test_case(boost::unit_test::callback0<boost::unit_test::ut_detail::unused>
const&, boost::unit_test::basic_cstring<char const>)]+0x1d): undefined reference to
`boost::unit_test::ut_detail::normalize_test_case_name(boost::unit_test::basic_cstring<char
const>)'
bTest.cpp:(.text._ZN5boost9unit_test14make_test_caseERKNS0_9callback0INS0_9ut_detail6unusedEEENS0_13basic_cstringIKcEE[boost::unit_test::make_test_case(boost::unit_test::callback0<boost::unit_test::ut_detail::unused>
const&, boost::unit_test::basic_cstring<char const>)]+0x5d): undefined reference to
`boost::unit_test::test_case::test_case(boost::unit_test::basic_cstring<char const>,
boost::unit_test::callback0<boost::unit_test::ut_detail::unused> const&)'
/tmp/ccZ8w6Wa.o: In function `boost::unit_test::unit_test_log_t::~unit_test_log_t()':
bTest.cpp:(.text._ZN5boost9unit_test15unit_test_log_tD2Ev[_ZN5boost9unit_test15unit_test_log_tD5Ev]+0xb):
undefined reference to `vtable for boost::unit_test::unit_test_log_t'
collect2: ld returned 1 exit status

I also try to install sudo apt-get install libboost-dev-all still same error.

Please help me how to solve this problem. Thanks in advance.

share|improve this question

1 Answer 1

i got the solution its order of the command instead of using g++ -o hello -lboost_unit_test_framework hello.cpp (which used to work in earlier version) change to g++ -o hello hello.cpp -lboost_unit_test_framework

This works fine.

I referred to http://stackoverflow.com/questions/7755668/linking-against-boost-thread-fails-under-ubuntu-11-10

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.