質問

ブーストライブラリとリンクしている間、私はほとんど問題に直面しています。私は実行しようとしています シンプルなタイマープログラム

しかし、エラー以下のプログラムを実行するとき

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

これに関する簡単なポインターはありますか?

役に立ちましたか?

解決

指定することを覚えていましたか -pthread 同じように? GCCマンページから:

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

POSIXスレッドを使用するコードで必要です。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top