简体   繁体   English

促进图书馆链接问题

[英]Boost Libraries Linking Issues

I am facing few problems while linking with boost libraries. 与Boost库链接时,我遇到了一些问题。 I am trying to execute simple timer program 我正在尝试执行简单的计时器程序

But when I execute the program getting below errors 但是当我执行程序时出现以下错误

~/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

I've included _I ~/boost_1_48_0/ -L ~/boost_1_48_0/stage/lib -lboost-system 我已经包含_I ~/boost_1_48_0/ -L ~/boost_1_48_0/stage/lib -lboost-system

Any quick pointers on this? 任何快速的指示吗?

Did you remember to specify -pthread as well? 您还记得还指定了-pthread吗? From GCC manpage: 从GCC手册页:

  -pthread Add support for multithreading using the POSIX threads library. This option sets flags for both the preprocessor and linker. 

It is required with code that uses POSIX threads. 使用POSIX线程的代码是必需的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM