Boost logo

Boost Users :

Subject: [Boost-users] Help compiling/linking boost example
From: zaphod742 . (purnish.dave_at_[hidden])
Date: 2014-01-24 22:58:04


I installed boost-all-dev using apt-get on Ubuntu.
I am trying to compile this example program of sync_client.cpp
http://www.boost.org/doc/libs/1_45_0/doc/html/boost_asio/example/http/client/sync_client.cpp

I get this error ..

$ sudo g++ sync_client.cpp -I usr/local/include/boost -L /usr/local/lib
/tmp/ccaVkCWp.o: In function
`__static_initialization_and_destruction_0(int, int)':
sync_client.cpp:(.text+0xd61): undefined reference to
`boost::system::generic_category()'
sync_client.cpp:(.text+0xd6d): undefined reference to
`boost::system::generic_category()'
sync_client.cpp:(.text+0xd79): undefined reference to
`boost::system::system_category()'
/tmp/ccaVkCWp.o: In function `boost::system::error_code::error_code()':
sync_client.cpp:(.text._ZN5boost6system10error_codeC2Ev[_ZN5boost6system10error_codeC5Ev]+0x17):
undefined reference to `boost::system::system_category()'
/tmp/ccaVkCWp.o: In function `boost::asio::error::get_system_category()':
sync_client.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[boost::asio::error::get_system_category()]+0x5):
undefined reference to `boost::system::system_category()'
/tmp/ccaVkCWp.o: In function
`boost::asio::detail::posix_tss_ptr_create(unsigned int&)':
sync_client.cpp:(.text._ZN5boost4asio6detail20posix_tss_ptr_createERj[boost::asio::detail::posix_tss_ptr_create(unsigned
int&)]+0x19): undefined reference to `pthread_key_create'
/tmp/ccaVkCWp.o: In function
`boost::asio::detail::posix_thread::~posix_thread()':
sync_client.cpp:(.text._ZN5boost4asio6detail12posix_threadD2Ev[_ZN5boost4asio6detail12posix_threadD5Ev]+0x26):
undefined reference to `pthread_detach'
/tmp/ccaVkCWp.o: In function `boost::asio::detail::posix_thread::join()':
sync_client.cpp:(.text._ZN5boost4asio6detail12posix_thread4joinEv[boost::asio::detail::posix_thread::join()]+0x2b):
undefined reference to `pthread_join'
/tmp/ccaVkCWp.o: In function
`boost::asio::detail::posix_tss_ptr<boost::asio::detail::call_stack<boost::asio::detail::task_io_service>::context>::~posix_tss_ptr()':
sync_client.cpp:(.text._ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_15task_io_serviceEE7contextEED2Ev[_ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_15task_io_serviceEE7contextEED5Ev]+0x15):
undefined reference to `pthread_key_delete'
/tmp/ccaVkCWp.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()':
sync_client.cpp:(.text._ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_14strand_service11strand_implEE7contextEED2Ev[_ZN5boost4asio6detail13posix_tss_ptrINS1_10call_stackINS1_14strand_service11strand_implEE7contextEED5Ev]+0x15):
undefined reference to `pthread_key_delete'
collect2: ld returned 1 exit status

How can I solve this error?



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net