Boost 静态库怎么不行
只是一个简单的linux下的测试,用的cmake写的
库连接成这样就可以(默认也是先用动态库)
target_link_libraries(test boost_thread boost_system)
或者指定动态库
target_link_libraries(test libboost_thread.so libboost_system.so)
但是指定静态库就不行,有人知道为什么吗
target_link_libraries(test libboost_thread.a libboost_system.a)
会出现类似这种错误
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../libboost_thread.a(thread.o): In function `boost::detail::get_current_thread_data()':
thread.cpp:(.text+0x2d): undefined reference to `pthread_key_create'
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../libboost_thread.a(thread.o): In function `boost::detail::set_current_thread_data(boost::detail::thread_data_base*)':
thread.cpp:(.text+0x6d): undefined reference to `pthread_key_create'
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../libboost_thread.a(thread.o): In function `boost::thread::start_thread_noexcept()':
thread.cpp:(.text+0xe3): undefined reference to `pthread_create'