Boost logo

Boost Users :

From: Noah Roberts (roberts.noah_at_[hidden])
Date: 2008-05-16 19:12:26


Pierre-Jules Tremblay wrote:
> Noah,
>
> Your language and tone are abusive. Gennadiy is not saying that you
> are not seeing a problem: he is telling you what is the only possible
> reason why you are seeing this problem (and he is right).
>
> There are two things you can try:
>
> 1) tell us what platform and compiler you use, print out the linker
> command issued by your build system and let us see it, and ask nicely
> for help.

g++ -I../include -g -O2 -lboost_unit_test_framework-s -o commands
commands.o command.o
commands.o: In function `test_construct()':
/home/nroberts/projects/ai/wumpus2/tests/commands.cpp:11: undefined
reference to
`boost::test_tools::tt_detail::check_impl(boost::test_tools::predicate_result
const&, boost::basic_wrap_stringstream<char>&,
boost::unit_test::basic_cstring<char const>, unsigned long,
boost::test_tools::tt_detail::tool_level,
boost::test_tools::tt_detail::check_type, unsigned long, ...)'

#include <boost/test/unit_test.hpp>

/*
 * Upgrade of boost changed something. I can't get it to link correctly.
 * Going to have to forego the standard unit tests until I can get help
 * from the boost list.
 */

void test_construct()
{
  BOOST_CHECK(false);
}

using namespace boost::unit_test;

test_suite * init_unit_test_suite(int,char**)
{
  test_suite * test = BOOST_TEST_SUITE("wumpus commands");
  test->add(BOOST_TEST_CASE(&test_construct));
  return test;
}

Change BOOST_CHECK to BOOST_ASSERT and I get this output:

g++ -I../include -g -O2 -lboost_unit_test_framework-s -o commands
commands.o command.o
make[2]: Leaving directory `/home/nroberts/projects/ai/wumpus2/tests'
make check-TESTS
make[2]: Entering directory `/home/nroberts/projects/ai/wumpus2/tests'
Running 1 test case...
commands: commands.cpp:11: void test_construct(): Assertion `false' failed.

*** No errors detected
PASS: commands
==================
All 1 tests passed
==================

I do hope that ends the debate on whether I am linking to the unit test
framework library. This is the library I've used in past versions of
boost (minus the -s). I've simply asked if there is a different library
I need to link to since this one quite obviously does NOT have the
definition I need.

Platform is Gentoo Linux 64, g++ 4.1.1. If someone needs more
information that will help figure out what the problem is instead of
saying it doesn't exist, I will be *more* than happy to provide it.

*-s is being used because the library I used to link to, without the -s,
complains that main is undefined and fails to link. "-s" means static
apparently and it is, indeed, a static library on my system. Here is a
listing in case you don't believe me:

/usr/lib/libboost_unit_test_framework-mt-s.a
/usr/lib/libboost_unit_test_framework-mt.so
/usr/lib/libboost_unit_test_framework-s.a
/usr/lib/libboost_unit_test_framework.so

Perhaps later I can look into the build process that was used to build
boost. I did use portage. If, indeed, that symbol is supposed to be
found in this library then something went wrong somewhere either in
portage or in the jam system. I saw nothing off hand in the emerge
script that would do anything weird but perhaps I missed something.

BTW, if I don't tell the linker to link to this library specifically I
do get the expected output of:

g++ -I../include -g -O2 -o commands commands.o command.o
/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/../../../../lib64/crt1.o: In
function `_start':
init.c:(.text+0x20): undefined reference to `main'
commands.o: In function `init_unit_test_suite(int, char**)':
/home/nroberts/projects/ai/wumpus2/tests/commands.cpp:18: undefined
reference to
`boost::unit_test::test_suite::test_suite(boost::unit_test::basic_cstring<char
const>)'
commands.o: In function `init_unit_test_suite(int, char**)':
/usr/include/boost/test/unit_test_suite_impl.hpp:247: undefined
reference to
`boost::unit_test::ut_detail::normalize_test_case_name(boost::unit_test::basic_cstring<char
const>)'
/usr/include/boost/test/unit_test_suite_impl.hpp:247: 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&)'
commands.o: In function `init_unit_test_suite(int, char**)':
/home/nroberts/projects/ai/wumpus2/tests/commands.cpp:19: undefined
reference to
`boost::unit_test::test_suite::add(boost::unit_test::test_unit*,
unsigned long, unsigned int)'
commands.o: In function `unit_test_log_t':
/usr/include/boost/test/unit_test_log.hpp:126: undefined reference to
`vtable for boost::unit_test::unit_test_log_t'
commands.o: In function `test_construct()':
/home/nroberts/projects/ai/wumpus2/tests/commands.cpp:11: undefined
reference to
`boost::unit_test::unit_test_log_t::set_checkpoint(boost::unit_test::basic_cstring<char
const>, unsigned long, boost::unit_test::basic_cstring<char const>)'
/home/nroberts/projects/ai/wumpus2/tests/commands.cpp:11: undefined
reference to
`boost::test_tools::tt_detail::check_impl(boost::test_tools::predicate_result
const&, boost::basic_wrap_stringstream<char>&,
boost::unit_test::basic_cstring<char const>, unsigned long,
boost::test_tools::tt_detail::tool_level,
boost::test_tools::tt_detail::check_type, unsigned long, ...)'
commands.o: In function `unit_test_log_t':
/usr/include/boost/test/unit_test_log.hpp:126: undefined reference to
`vtable for boost::unit_test::unit_test_log_t'
collect2: ld returned 1 exit status


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