C++ 促进图书馆与问题的联系

C++ 促进图书馆与问题的联系,c++,boost,boost-asio,ubuntu-11.10,C++,Boost,Boost Asio,Ubuntu 11.10,在与boost库链接时,我遇到了一些问题。我正在尝试执行 但当我执行程序时,会出现以下错误 ~/boost_1_48_0/boost/asio/detail/impl/posix_tss_ptr.ipp:34: undefined reference to `pthread_key_create' ./timer.o: In function `~posix_tss_ptr': /~/boost_1_48_0/boost/asio/detail/posix_tss_ptr.hpp:48: und

在与boost库链接时,我遇到了一些问题。我正在尝试执行

但当我执行程序时,会出现以下错误

~/boost_1_48_0/boost/asio/detail/impl/posix_tss_ptr.ipp:34: undefined reference to `pthread_key_create'
./timer.o: In function `~posix_tss_ptr': /~/boost_1_48_0/boost/asio/detail/posix_tss_ptr.hpp:48: undefined reference to `pthread_key_delete' 
./timer.o: In function `boost::asio::detail::posix_tss_ptr<boost::asio::detail::call_stack<boost::asio::detail::task_io_service, boost::asio::detail::task_io_service::thread_info>::context>::operator boost::asio::detail::call_stack<boost::asio::detail::task_io_service, boost::asio::detail::task_io_service::thread_info>::context*() const': ~/boost_1_48_0/boost/asio/detail/posix_tss_ptr.hpp:54: undefined reference to `pthread_getspecific'
./timer.o: In function `~posix_tss_ptr': ~/boost_1_48_0/boost/asio/detail/posix_tss_ptr.hpp:48: undefined reference to `pthread_key_delete' collect2: ld returned 1 exit status
~/boost\u 1\u 48\u 0/boost/asio/detail/impl/posix\u tss\u ptr.ipp:34:未定义对“pthread\u key\u create”的引用
./timer.o:在函数“~posix_tss_ptr”中:/~/boost_1_48_0/boost/asio/detail/posix_tss_ptr.hpp:48:未定义对“pthread\u key\u delete”的引用
/timer.o:在函数'boost::asio::detail::posix_tsu ptr::operator boost::asio::detail::call_stack::context*()const':~/boost_1_48_0/boost/asio/detail/posix_tsu ptr.hpp:54:对'pthread_getspecific'的未定义引用
./timer.o:在函数“~posix_tsu ptr”中:~/boost_1_48_0/boost/asio/detail/posix_tsu ptr.hpp:48:对“pthread_key_delete”集合的未定义引用2:ld返回了1个退出状态
我已经包括了
\u I~/boost\u 1\u 48\u 0/-L~/boost\u 1\u 48\u 0/stage/lib-lboost系统


有关于这个的快速指针吗?

您还记得指定
-pthread
吗?从GCC手册页:


这是使用POSIX线程的代码所必需的。

显然,假设您首先使用的是GCC。谢谢reko_\t,我已经包含了它,它工作得很好。但是,我现在面临运行时错误,说libboost_system.so.1.48.0:无法打开共享对象文件:没有这样的文件或目录。它实际上存在于/stage/lib目录中。我遗漏了一些东西。我正在使用EclipseCDT并尝试在那里运行。您的系统必须能够从给定路径集中找到共享库。如果共享库位于非标准目录中,则可以将该目录包含在
LD\u library\u PATH
环境变量中。执行以下操作:
export LD_LIBRARY_PATH=“/PATH/to/stage/lib:$LD_LIBRARY_PATH”
,然后重试。再次出现运气不佳的情况,我的LD_LIBRARY_PATH没有值,现在我正确设置了stage路径,但仍然抛出相同的错误。有其他选择吗?如果链接到
-lboost\u线程
,会发生什么情况?
   -pthread
       Add support for multithreading using the POSIX threads library.
       This option sets flags for both the preprocessor and linker.