Boost 库链接问题

发布于 2025-01-06 21:14:40 字数 1210 浏览 1 评论 0原文

我在与 boost 库链接时遇到了一些问题。我正在尝试执行 简单的计时器程序< /a>

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

~/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 ~/boost_1_48_0/ -L ~/boost_1_48_0/stage/lib -lboost-system

有什么快速指南吗?

I am facing few problems while linking with boost libraries. 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

Any quick pointers on this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无法言说的痛 2025-01-13 21:14:40

您还记得指定 -pthread 吗?来自 GCC 联机帮助页:

<前><代码> -pthread
使用 POSIX 线程库添加对多线程的支持。
该选项为预处理器和链接器设置标志。

使用 POSIX 线程的代码需要它。

Did you remember to specify -pthread as well? From GCC manpage:

   -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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文