我在 thrift-0.9.3 包中看到了编译问题(我确实从https://thrift.apache.org/download)。在 lib/cpp/test 中观察到一些链接错误。有人能建议我应该安装哪个版本的 Boost 吗?我尝试了 1.54 和 1.55。我无法理解这些错误。我需要共享库文件 libthrift-0.9.3.so 作为其他包的依赖项。
我的 ubuntu 版本是 14.04 trusty 和内核 3.19.0-56-generic。
我在 boost 包中看到以下错误日志。
.
.
Making all in test
make[4]: Entering directory `/home/gou/nt/nfp/dependencies/thrift/thrift-0.9.3/lib/cpp/test'
make all-am
make[5]: Entering directory `/home/gou/nt/nfp/dependencies/thrift/thrift-0.9.3/lib/cpp/test'
/bin/bash ../../../libtool --tag=CXX --mode=link g++ -Wall -Wextra -pedantic -g -O2 -std=c++11 -L/usr/lib/x86_64-linux-gnu -o libtestgencpp.la gen-cpp/DebugProtoTest_types.lo gen-cpp/EnumTest_types.lo gen-cpp/OptionalRequiredTest_types.lo gen-cpp/Recursive_types.lo gen-cpp/ThriftTest_types.lo gen-cpp/ThriftTest_constants.lo gen-cpp/TypedefTest_types.lo ThriftTest_extras.lo DebugProtoTest_extras.lo ../../../lib/cpp/libthrift.la -lssl -lcrypto -lrt -lpthread
depbase=`echo Benchmark.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
g++ -DHAVE_CONFIG_H -I. -I../../.. -I../../../lib/cpp/src/thrift -I/usr/include -I../../../lib/cpp/src -D__STDC_LIMIT_MACROS -Wall -Wextra -pedantic -g -O2 -std=c++11 -MT Benchmark.o -MD -MP -MF $depbase.Tpo -c -o Benchmark.o Benchmark.cpp &&\
mv -f $depbase.Tpo $depbase.Po
/bin/bash ../../../libtool --tag=CXX --mode=link g++ -Wall -Wextra -pedantic -g -O2 -std=c++11 -L/usr/lib/x86_64-linux-gnu -o processor_test processor/ProcessorTest.o processor/EventLog.o processor/ServerThread.o libprocessortest.la ../../../lib/cpp/libthrift.la ../../../lib/cpp/libthriftnb.la /usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.a -L/usr/lib/x86_64-linux-gnu -levent -lssl -lcrypto -lrt -lpthread
libtool: link: ar cru .libs/libtestgencpp.a gen-cpp/.libs/DebugProtoTest_types.o gen-cpp/.libs/EnumTest_types.o gen-cpp/.libs/OptionalRequiredTest_types.o gen-cpp/.libs/Recursive_types.o gen-cpp/.libs/ThriftTest_types.o gen-cpp/.libs/ThriftTest_constants.o gen-cpp/.libs/TypedefTest_types.o .libs/ThriftTest_extras.o .libs/DebugProtoTest_extras.o
libtool: link: g++ -Wall -Wextra -pedantic -g -O2 -std=c++11 -o .libs/processor_test processor/ProcessorTest.o processor/EventLog.o processor/ServerThread.o -L/usr/lib/x86_64-linux-gnu ./.libs/libprocessortest.a ../../../lib/cpp/.libs/libthrift.so ../../../lib/cpp/.libs/libthriftnb.so /usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.a -levent -lssl -lcrypto -lrt -lpthread
libtool: link: ranlib .libs/libtestgencpp.a
libtool: link: ( cd ".libs" && rm -f "libtestgencpp.la" && ln -s "../libtestgencpp.la" "libtestgencpp.la" )
processor/ProcessorTest.o: In function `operator<< <char const*>':
/usr/local/include/boost/test/tools/detail/print_helper.hpp:172: undefined reference to `boost::test_tools::tt_detail::print_log_value<char const*>::operator()(std::ostream&, char const*)'
processor/ProcessorTest.o: In function `boost::unit_test::make_test_case(boost::function<void ()> const&, boost::unit_test::basic_cstring<char const>, boost::unit_test::basic_cstring<char const>, unsigned long)':
/usr/local/include/boost/test/tree/test_unit.hpp:249: undefined reference to `boost::unit_test::test_case::test_case(boost::unit_test::basic_cstring<char const>, boost::unit_test::basic_cstring<char const>, unsigned long, boost::function<void ()> const&)'
processor/ProcessorTest.o: In function `bool boost::test_tools::tt_detail::check_frwd<boost::test_tools::tt_detail::equal_impl_frwd, char const*, char const*>(boost::test_tools::tt_detail::equal_impl_frwd, boost::unit_test::lazy_ostream const&, boost::unit_test::basic_cstring<char const>, unsigned long, boost::test_tools::tt_detail::tool_level, boost::test_tools::tt_detail::check_type, char const* const&, char const*, char const* const&, char const*)':
/usr/loc*al/include/boost/test/tools/old/impl.hpp:92: undefined reference to `boost::test_tools::tt_detail::report_assertion(boost::test_tools::assertion_result const&, boost::unit_test::lazy_ostream const&, 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, ...)'
processor/ProcessorTest.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 long, boost::test_tools::tt_detail::tool_level, boost::test_tools::tt_detail::check_type, unsigned int const&, char const*, unsigned int const&, char const*)':
/usr/local/include/boost/test/tools/old/impl.hpp:92: undefined reference to `boost::test_tools::tt_detail::report_assertion(boost::test_tools::assertion_result const&, boost::unit_test::lazy_ostream const&, 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, ...)'
processor/ProcessorTest.o: In function `bool boost::test_tools::tt_detail::check_frwd<boost::test_tools::tt_detail::equal_impl_frwd, std::string, std::string>(boost::test_tools::tt_detail::equal_impl_frwd, boost::unit_test::lazy_ostream const&, boost::unit_test::basic_cstring<char const>, unsigned long, boost::test_tools::tt_detail::tool_level, boost::test_tools::tt_detail::check_type, std::string const&, char const*, std::string const&, char const*)':
/usr/local/include/boost/test/tools/old/impl.hpp:92: undefined reference to `boost::test_tools::tt_detail::report_assertion(boost::test_tools::assertion_result const&, boost::unit_test::lazy_ostream const&, 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, ...)'
processor/ProcessorTest.o: In function `bool boost::test_tools::tt_detail::check_frwd<boost::test_tools::tt_detail::ne_impl, unsigned long, unsigned long>(boost::test_tools::tt_detail::ne_impl, boost::unit_test::lazy_ostream const&, 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 const&, char const*, unsigned long const&, char const*)':
/usr/local/include/boost/test/tools/old/impl.hpp:92: undefined reference to `boost::test_tools::tt_detail::report_assertion(boost::test_tools::assertion_result const&, boost::unit_test::lazy_ostream const&, 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, ...)'
processor/ProcessorTest.o: In function `bool boost::test_tools::tt_detail::check_frwd<boost::test_tools::tt_detail::ne_impl, unsigned int, unsigned int>(boost::test_tools::tt_detail::ne_impl, boost::unit_test::lazy_ostream const&, boost::unit_test::basic_cstring<char const>, unsigned long, boost::test_tools::tt_detail::tool_level, boost::test_tools::tt_detail::check_type, unsigned int const&, char const*, unsigned int const&, char const*)':
/usr/local/include/boost/test/tools/old/impl.hpp:92: undefined reference to `boost::test_tools::tt_detail::report_assertion(boost::test_tools::assertion_result const&, boost::unit_test::lazy_ostream const&, 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, ...)'
processor/ProcessorTest.o:/usr/local/include/boost/test/tools/old/impl.hpp:92: more undefined references to `boost::test_tools::tt_detail::report_assertion(boost::test_tools::assertion_result const&, boost::unit_test::lazy_ostream const&, 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, ...)' follow
processor/ProcessorTest.o: In function `__static_initialization_and_destruction_0':
/home/gou/nt/nfp/dependencies/thrift/thrift-0.9.3/lib/cpp/test/processor/ProcessorTest.cpp:894: undefined reference to `boost::unit_test::ut_detail::auto_test_unit_registrar::auto_test_unit_registrar(boost::unit_test::test_case*, boost::unit_test::decorator::collector&, unsigned long)'
/home/gou/nt/nfp/dependencies/thrift/thrift-0.9.3/lib/cpp/test/processor/ProcessorTest.cpp:894: undefined reference to `boost::unit_test::ut_detail::auto_test_unit_registrar::auto_test_unit_registrar(boost::unit_test::test_case*, boost::unit_test::decorator::collector&, unsigned long)'
/home/gou/nt/nfp/dependencies/thrift/thrift-0.9.3/lib/cpp/test/processor/ProcessorTest.cpp:894: undefined reference to `boost::unit_test::ut_detail::auto_test_unit_registrar::auto_test_unit_registrar(boost::unit_test::test_case*, boost::unit_test::decorator::collector&, unsigned long)'
/home/gou/nt/nfp/dependencies/thrift/thrift-0.9.3/lib/cpp/test/processor/ProcessorTest.cpp:894: undefined reference to `boost::unit_test::ut_detail::auto_test_unit_registrar::auto_test_unit_registrar(boost::unit_test::test_case*, boost::unit_test::decorator::collector&, unsigned long)'
/home/gou/nt/nfp/dependencies/thrift/thrift-0.9.3/lib/cpp/test/processor/ProcessorTest.cpp:894: undefined reference to `boost::unit_test::ut_detail::auto_test_unit_registrar::auto_test_unit_registrar(boost::unit_test::test_case*, boost::unit_test::decorator::collector&, unsigned long)'
processor/ProcessorTest.o:/home/gou/nt/nfp/dependencies/thrift/thrift-0.9.3/lib/cpp/test/processor/ProcessorTest.cpp:894: more undefined references to `boost::unit_test::ut_detail::auto_test_unit_registrar::auto_test_unit_registrar(boost::unit_test::test_case*, boost::unit_test::decorator::collector&, unsigned long)' follow
processor/ProcessorTest.o: In function `bool boost::test_tools::tt_detail::check_frwd<boost::test_tools::tt_detail::equal_impl_frwd, int, unsigned long>(boost::test_tools::tt_detail::equal_impl_frwd, boost::unit_test::lazy_ostream const&, boost::unit_test::basic_cstring<char const>, unsigned long, boost::test_tools::tt_detail::tool_level, boost::test_tools::tt_detail::check_type, int const&, char const*, unsigned long const&, char const*)':
/usr/local/include/boost/test/tools/old/impl.hpp:92: undefined reference to `boost::test_tools::tt_detail::report_assertion(boost::test_tools::assertion_result const&, boost::unit_test::lazy_ostream const&, 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, ...)'
processor/ProcessorTest.o: In function `bool boost::test_tools::tt_detail::check_frwd<boost::test_tools::tt_detail::equal_impl_frwd, char [4], std::string>(boost::test_tools::tt_detail::equal_impl_frwd, boost::unit_test::lazy_ostream const&, boost::unit_test::basic_cstring<char const>, unsigned long, boost::test_tools::tt_detail::tool_level, boost::test_tools::tt_detail::check_type, char const (&) [4], char const*, std::string const&, char const*)':
/usr/local/include/boost/test/tools/old/impl.hpp:92: undefined reference to `boost::test_tools::tt_detail::report_assertion(boost::test_tools::assertion_result const&, boost::unit_test::lazy_ostream const&, 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, ...)'
processor/ProcessorTest.o: In function `bool boost::test_tools::tt_detail::check_frwd<boost::test_tools::tt_detail::equal_impl_frwd, char [5], std::string>(boost::test_tools::tt_detail::equal_impl_frwd, boost::unit_test::lazy_ostream const&, boost::unit_test::basic_cstring<char const>, unsigned long, boost::test_tools::tt_detail::tool_level, boost::test_tools::tt_detail::check_type, char const (&) [5], char const*, std::string const&, char const*)':
/usr/local/include/boost/test/tools/old/impl.hpp:92: undefined reference to `boost::test_tools::tt_detail::report_assertion(boost::test_tools::assertion_result const&, boost::unit_test::lazy_ostream const&, 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, ...)'
processor/ProcessorTest.o: In function `check_frwd<boost::test_tools::tt_detail::ne_impl, unsigned int, unsigned int>':
/usr/local/include/boost/test/tools/old/impl.hpp:92: undefined reference to `boost::test_tools::tt_detail::report_assertion(boost::test_tools::assertion_result const&, boost::unit_test::lazy_ostream const&, 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, ...)'
/usr/local/include/boost/test/tools/old/impl.hpp:92: undefined reference to `boost::test_tools::tt_detail::report_assertion(boost::test_tools::assertion_result const&, boost::unit_test::lazy_ostream const&, 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, ...)'
processor/ProcessorTest.o:/usr/local/include/boost/test/tools/old/impl.hpp:92: more undefined references to `boost::test_tools::tt_detail::report_assertion(boost::test_tools::assertion_result const&, boost::unit_test::lazy_ostream const&, 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, ...)' follow
collect2: error: ld returned 1 exit status
make[5]: *** [processor_test] Error 1
make[5]: *** Waiting for unfinished jobs....
make[5]: Leaving directory `/home/gou/nt/nfp/dependencies/thrift/thrift-0.9.3/lib/cpp/test'
make[4]: *** [all] Error 2
make[4]: Leaving directory `/home/gou/nt/nfp/dependencies/thrift/thrift-0.9.3/lib/cpp/test'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/gou/nt/nfp/dependencies/thrift/thrift-0.9.3/lib/cpp'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/gou/nt/nfp/dependencies/thrift/thrift-0.9.3/lib'
ake[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/gou/nt/nfp/dependencies/thrift/thrift-0.9.3'
make: *** [all] Error 2
答案1
我删除了手动安装的旧 boost 版本,然后使用 libboost-all-dev 安装新版本。我分别在 /usr/lib/x86_64-linux-gnu/ 或 /usr/local/lib 下看到了新旧 boost 的所有 .so 文件。当我使用 apt-get 删除旧 boost 包时,它们没有被自动删除。但无论如何,我设法将库位置作为 /usr/local/lib 提供给 thrift-0.9.3 的 .configure(即 ./configure --with-boost-libdir=/usr/local/lib)文件,并能够成功编译它。