次のコードがあります。
#include <iostream>
#define BOOST_TEST_MODULE my test
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_CASE( tmp_test )
{
std::string str("");
std::cout << "This is a simple test!" << std::endl;
}
//EOF
エラーなしでコンパイルおよびリンクします。
しかし、次のコードを使用しようとすると
#include <iostream>
#define BOOST_TEST_MODULE my test
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_CASE( tmp_test )
{
std::string str("");
BOOST_CHECK_EQUAL(str.length(), (size_t)0);
std::cout << "This is a simple test!" << std::endl;
}
//EOF
エラーが発生します:
ubuntu% g++ -std=c++0x -static -L/usr/local/lib -lboost_unit_test_framework boost_test_eq.cpp -o boost_test_eq
/tmp/ccJL5Dxk.o: In function `bool boost::test_tools::tt_detail::check_frwd<boost::test_tools::tt_detail::equal_impl_frwd, unsigned int, unsigned int>(boost::test_tools::tt_detail::equal_impl_frwd, 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 const&, char const*, unsigned int const&, char const*)':
boost_test_square_eq.cpp:(.text._ZN5boost10test_tools9tt_detail10check_frwdINS1_15equal_impl_frwdEjjEEbT_RKNS_9unit_test12lazy_ostreamENS5_13basic_cstringIKcEEjNS1_10tool_levelENS1_10check_typeERKT0_PSA_RKT1_SH_[bool boost::test_tools::tt_detail::check_frwd<boost::test_tools::tt_detail::equal_impl_frwd, unsigned int, unsigned int>(boost::test_tools::tt_detail::equal_impl_frwd, 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 const&, char const*, unsigned int const&, char const*)]+0xe9): 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, ...)'
collect2: ld returned 1 exit status
ここで何が問題なのですか?