Boost logo

Boost Users :

From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2006-07-10 02:20:34


If we exclude error in a library, when symbol is actually missing, there are not so many reasons that may cause undefined symbol error:

1. Library is missing from link command
2. Library is binary incompatible with test module code. The reason could be: different compiler version or different compilation options used for library and test module.
3. For some compilers. library should be listed before object files that refer to it.
4. Library is built improperly. Some object files are missing, for example. Using nm command usually allows to detect this.

HTH.

Gennadiy
  "Josh" <josh1_2000_at_[hidden]> wrote in message news:20060707165513.95719.qmail_at_web35302.mail.mud.yahoo.com...
  I have a very simple program
  ********************************************************************
  #include <iostream>
  #include <boost/test/unit_test.hpp>
  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<char, std::char_traits<char>, std::allocator<char> >)':
  : undefined reference to `boost::unit_test::ut_detail::normalize_test_case_name(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
  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'



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net