Boost logo

Boost Users :

Subject: Re: [Boost-users] Asio does not compile
From: Thomas Heller (thom.heller_at_[hidden])
Date: 2011-08-30 06:07:34


On Tuesday, August 30, 2011 11:08:56 AM Alessandro Candini wrote:
> My code (simplyfication of this:
> http://www.boost.org/doc/libs/1_47_0/doc/html/boost_asio/tutorial/tuttimer1/
> src.html):

Being pedantic ... It does compile, the linker doesn't find the symbols.
You need to link against the boost system and pthread library

>
> #include <iostream>
> #include </usr/local/include/boost/asio.hpp> // Boost version 1.47.0
> int main() { return 0; }
>
> Compilation command:
> g++ -Wall -o timer1 timer1.cpp
>
> Error:
> /tmp/ccGUgnoD.o: In function
> `__static_initialization_and_destruction_0(int, int)':
> timer1.cpp:(.text+0x52): undefined reference to
> `boost::system::generic_category()'
> timer1.cpp:(.text+0x5e): undefined reference to
> `boost::system::generic_category()'
> timer1.cpp:(.text+0x6a): undefined reference to
> `boost::system::system_category()'
> /tmp/ccGUgnoD.o: In function `boost::asio::error::get_system_category()':
> timer1.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[boost::asio::e
> rror::get_system_category()]+0x5): undefined reference to
> `boost::system::system_category()'
> /tmp/ccGUgnoD.o: In function
> `boost::asio::detail::posix_tss_ptr_create(unsigned int&)':
> timer1.cpp:(.text._ZN5boost4asio6detail20posix_tss_ptr_createERj[boost::asio
> ::detail::posix_tss_ptr_create(unsigned int&)]+0x19): undefined reference to
> `pthread_key_create'
> /tmp/ccGUgnoD.o: In function
> `boost::asio::detail::posix_tss_ptr<boost::asio::detail::call_stack<boost::a
> sio::detail::task_io_service>::context>::~posix_tss_ptr()':
> timer1.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/ccGUgnoD.o: In function
> `boost::asio::detail::posix_tss_ptr<boost::asio::detail::call_stack<boost::a
> sio::detail::strand_service::strand_impl>::context>::~posix_tss_ptr()':
> timer1.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
> make: *** [all] Error 1
>
> Any ideas?
>
> Thanks in advance.


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