请问linux上如何编译使用boost:thread的程序
我在windows上可以正确编译通过
我使用的boost是1.42.0
centos5.5
使用g++ 编译boost自带的example都不行
我这样编译的
g++ testBoostThread.cpp -o test -LBOOST_LIB
其中BOOST_LIB=/usr/lib/boost
我编译boost的时候将60多个文件都拷到这里了
且编译使用boost::timer的程序就可以通过
请问这是怎么回事
错误如下:
/usr/lib/boost/libboost_thread.a(thread.o): In function `boost::detail::set_
current_thread_data(boost::detail::thread_data_base*)':
thread.cpp:(.text+0xca): undefined reference to `pthread_setspecific'
/usr/lib/boost/libboost_thread.a(thread.o): In function `boost::detail::(ano
nymous namespace)::create_current_thread_tls_key()':
thread.cpp:(.text+0xe6): undefined reference to `pthread_key_create'
/usr/lib/boost/libboost_thread.a(thread.o): In function `boost::detail::get_
current_thread_data()':
thread.cpp:(.text+0x113): undefined reference to `pthread_getspecific'
/usr/lib/boost/libboost_thread.a(thread.o): In function `boost::thread::deta
ch()':
thread.cpp:(.text+0x19f): undefined reference to `pthread_detach'
/usr/lib/boost/libboost_thread.a(thread.o): In function `boost::(anonymous n
amespace)::make_external_thread_data()':
thread.cpp:(.text+0x57e): undefined reference to `pthread_setspecific'
/usr/lib/boost/libboost_thread.a(thread.o): In function `boost::thread::star
t_thread()':
thread.cpp:(.text+0x8fe): undefined reference to `pthread_create'
/usr/lib/boost/libboost_thread.a(thread.o): In function `thread_proxy':
thread.cpp:(.text+0xb6d): undefined reference to `pthread_setspecific'
thread.cpp:(.text+0xbac): undefined reference to `pthread_setspecific'
/usr/lib/boost/libboost_thread.a(thread.o): In function `boost::this_thread:
:restore_interruption::~restore_interruption()':
thread.cpp:(.text+0xed3): undefined reference to `pthread_getspecific'
thread.cpp:(.text+0xef8): undefined reference to `pthread_getspecific'
/usr/lib/boost/libboost_thread.a(thread.o): In function `boost::detail::find
_tss_data(void const*)':
thread.cpp:(.text+0xf38): undefined reference to `pthread_getspecific'
/usr/lib/boost/libboost_thread.a(thread.o): In function `boost::this_thread:
:restore_interruption::restore_interruption(boost::this_thread::disable_inte
rruption&)':
thread.cpp:(.text+0xfdd): undefined reference to `pthread_getspecific'
/usr/lib/boost/libboost_thread.a(thread.o): In function `boost::this_thread:
:interruption_point()':
thread.cpp:(.text+0x1019): undefined reference to `pthread_getspecific'
/usr/lib/boost/libboost_thread.a(thread.o):thread.cpp:(.text+0x10ce): more u
ndefined references to `pthread_getspecific' follow
/usr/lib/boost/libboost_thread.a(thread.o): In function `boost::thread::time
d_join(boost::posix_time::ptime const&)':
thread.cpp:(.text+0x13a1): undefined reference to `pthread_join'
thread.cpp:(.text+0x1480): undefined reference to `pthread_getspecific'
/usr/lib/boost/libboost_thread.a(thread.o): In function `boost::thread::join
()':
thread.cpp:(.text+0x1730): undefined reference to `pthread_join'
/usr/lib/boost/libboost_thread.a(thread.o): In function `boost::this_thread:
:disable_interruption::disable_interruption()':
thread.cpp:(.text+0x1a37): undefined reference to `pthread_getspecific'
thread.cpp:(.text+0x1a71): undefined reference to `pthread_getspecific'
/usr/lib/boost/libboost_thread.a(thread.o): In function `boost::this_thread:
:disable_interruption::disable_interruption()':
thread.cpp:(.text+0x1eb7): undefined reference to `pthread_getspecific'
thread.cpp:(.text+0x1ef1): undefined reference to `pthread_getspecific'
/usr/lib/boost/libboost_thread.a(thread.o): In function `boost::this_thread:
:get_id()':
thread.cpp:(.text+0x1f39): undefined reference to `pthread_getspecific'
/usr/lib/boost/libboost_thread.a(thread.o):thread.cpp:(.text+0x2183): more u
ndefined references to `pthread_getspecific' follow
/usr/lib/boost/libboost_thread.a(once.o): In function `boost::detail::get_on
ce_per_thread_epoch()':
once.cpp:(.text+0x17): undefined reference to `pthread_once'
once.cpp:(.text+0x24): undefined reference to `pthread_getspecific'
once.cpp:(.text+0x4d): undefined reference to `pthread_setspecific'
/usr/lib/boost/libboost_thread.a(once.o): In function `create_epoch_tss_key'
:
once.cpp:(.text+0x86): undefined reference to `pthread_key_create'
collect2: ld 返回 1
[解决办法]
/usr/lib/boost/libboost_thread.a(once.o): In function `boost::detail::get_on
ce_per_thread_epoch()':
LZ注意看提示,明明就是没编译好,
缺少相应的函数实现。
在编译boost::thread库看看。