我想使用boost :: thread_specific_ptr,但需要知道要添加到我的gcc v3.4.6链接行的内容以定义它的用途:
/usr/include/boost/thread/tss.hpp:35: undefined reference to `boost::thread_resource_error::thread_resource_error()'
../../src/utility/ARCH.linux_26_i86/debug/libmyApp.a(system.o)(.gnu.linkonce.t._ZN5boost6detail3tssC1EPNS_9function1IvPvSaINS_13function_baseEEEE+0x5b):/usr/include/boost/thread/tss.hpp:35: undefined reference to `boost::thread_resource_error::~thread_resource_error()'
../../src/utility/ARCH.linux_26_i86/debug/libmyApp.a(system.o)(.gnu.linkonce.t._ZN5boost6detail3tssC1EPNS_9function1IvPvSaINS_13function_baseEEEE+0x60):/usr/include/boost/thread/tss.hpp:35: undefined reference to `typeinfo for boost::thread_resource_error'
../../src/utility/ARCH.linux_26_i86/debug/libmyApp.a(system.o)(.gnu.linkonce.t._ZN5boost6detail3tssC1EPNS_9function1IvPvSaINS_13function_baseEEEE+0x76):/usr/include/boost/thread/tss.hpp:38: undefined reference to `boost::detail::tss::init(boost::function1<void, void*, std::allocator<boost::function_base> >*)'
../../src/utility/ARCH.linux_26_i86/debug/libmyApp.a(system.o)(.gnu.linkonce.t._ZN5boost6detail3tssC1EPNS_9function1IvPvSaINS_13function_baseEEEE+0xd2):/usr/include/boost/thread/tss.hpp:43: undefined reference to `boost::thread_resource_error::thread_resource_error()'
../../src/utility/ARCH.linux_26_i86/debug/libmyApp.a(system.o)(.gnu.linkonce.t._ZN5boost6detail3tssC1EPNS_9function1IvPvSaINS_13function_baseEEEE+0xf8):/usr/include/boost/thread/tss.hpp:43: undefined reference to `boost::thread_resource_error::~thread_resource_error()'
../../src/utility/ARCH.linux_26_i86/debug/libmyApp.a(system.o)(.gnu.linkonce.t._ZN5boost6detail3tssC1EPNS_9function1IvPvSaINS_13function_baseEEEE+0xfd):/usr/include/boost/thread/tss.hpp:43: undefined reference to `typeinfo for boost::thread_resource_error'
../../src/utility/ARCH.linux_26_i86/debug/libmyApp.a(system.o)(.gnu.linkonce.t._ZNK5boost19thread_specific_ptrIN5Botan14AutoSeeded_RNGEE3getEv+0x11): In function `boost::thread_specific_ptr<Botan::AutoSeeded_RNG>::get() const':
/usr/include/boost/thread/tss.hpp:89: undefined reference to `boost::detail::tss::get() const'
../../src/utility/ARCH.linux_26_i86/debug/libmyApp.a(system.o)(.gnu.linkonce.t._ZN5boost19thread_specific_ptrIN5Botan14AutoSeeded_RNGEE5resetEPS2_+0x2f): In function `boost::thread_specific_ptr<Botan::AutoSeeded_RNG>::reset(Botan::AutoSeeded_RNG*)':
/usr/include/boost/thread/tss.hpp:97: undefined reference to `boost::detail::tss::set(void*)'
../../src/utility/ARCH.linux_26_i86/debug/libmyApp.a(system.o)(.gnu.linkonce.t._ZN5boost19thread_specific_ptrIN5Botan14AutoSeeded_RNGEE5resetEPS2_+0x4a):/usr/include/boost/thread/tss.hpp:98: undefined reference to `boost::detail::tss::cleanup(void*)'
我应该连接什么来定义所有这些?
在我的Ubuntu系统上,我使用-lboost_thread
(因为libboost_thread.so
已经在我的/usr/lib
中,我不需要任何-L
选项)。
如果您使用的是CMake
,您可以:
find_package(Boost COMPONENTS thread REQUIRED)
include_directories(${Boost_INCLUDE_DIR})
target_link_libraries(you_lib
${Boost_LIBRARIES}
)