Boost.Asio安装问题 [英] Boost.Asio installation issue
问题描述
我已经使用bjam install安装了boost库,但是当我编译程序时:
i have already installed boost libraries with bjam install, but when i'm compiling programme:
#include boost/asio.hpp
int main()
{
return 0;
}
发生此类错误:
/tmp/ccVR3eeF.o: In function `__static_initialization_and_destruction_0(int, int)':
sda.cpp:(.text+0x52): undefined reference to `boost::system::generic_category()'
sda.cpp:(.text+0x5e): undefined reference to `boost::system::generic_category()'
sda.cpp:(.text+0x6a): undefined reference to `boost::system::system_category()'
/tmp/ccVR3eeF.o: In function `boost::asio::error::get_system_category()':
sda.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[boost::asio::error::get_system_category()]+0x5): undefined reference to `boost::system::system_category()'
/tmp/ccVR3eeF.o: In function `boost::asio::detail::posix_tss_ptr_create(unsigned int&)':
sda.cpp:(.text._ZN5boost4asio6detail20posix_tss_ptr_createERj[boost::asio::detail::posix_tss_ptr_create(unsigned int&)]+0x19): undefined reference to `pthread_key_create'
/tmp/ccVR3eeF.o: In function `boost::asio::detail::posix_tss_ptr<boost::asio::detail::call_stack<boost::asio::detail::task_io_service>::context>::~posix_tss_ptr()':
sda.cpp:(.text._ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_15task_io_serviceEE7contextEED2Ev[boost::asio::detail::posix_tss_ptr<boost::asio::detail::call_stack<boost::asio::detail::task_io_service>::context>::~posix_tss_ptr()]+0x15): undefined reference to `pthread_key_delete'
/tmp/ccVR3eeF.o: In function `boost::asio::detail::posix_tss_ptr<boost::asio::detail::call_stack<boost::asio::detail::strand_service::strand_impl>::context>::~posix_tss_ptr()':
sda.cpp:(.text._ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_14strand_service11strand_implEE7contextEED2Ev[boost::asio::detail::posix_tss_ptr<boost::asio::detail::call_stack<boost::asio::detail::strand_service::strand_impl>::context>::~posix_tss_ptr()]+0x15): undefined reference to `pthread_key_delete'
collect2: ld returned 1 exit status
我该怎么办?我该如何建立这些库?
what do i have to do? how can i build those libraries?
推荐答案
Boost.Asio也需要Boost.System库.您需要在链接器命令行中添加-lboost_system
.
Boost.Asio requires the Boost.System library as well; you need to add -lboost_system
to your linker command line.
向程序添加功能时,可能还需要Boost的其他部分,例如Boost.Thread,Boost.Date_Time等.参见 http://www.boost.org/doc/libs/1_46_1/doc/html/boost_asio/using.html 了解详情.
As you add features to your program, you might also need other parts of Boost, like Boost.Thread, Boost.Date_Time, and so on. See http://www.boost.org/doc/libs/1_46_1/doc/html/boost_asio/using.html for details.
这篇关于Boost.Asio安装问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!