Boost logo

Boost Users :

Subject: Re: [Boost-users] Asio does not compile
From: Andreas Wehrmann (a.wehrmann_at_[hidden])
Date: 2011-08-30 06:22:46


On 08/30/2011 12:09 PM, Alessandro Candini wrote:
> On 30/08/11 12:04, Andreas Wehrmann wrote:
>> On 08/30/2011 11:08 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):
>>>
>>> #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::error::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::asio::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::asio::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.
>>>
>>
>> What platform are you trying to build that for?
>>
>> Regards
>>
>
> A 64 bit architecture:
>
> Linux office-007 2.6.38-11-generic #48-Ubuntu SMP Fri Jul 29 19:02:55
> UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
>

You need to link against the boost_system library "-lboost_system".
Btw. the subject is somewhat irritating as ASIO does indeed compile
but your program fails to link.

-- 
Dipl.-Ing. (FH) Andreas Wehrmann
Software Development
--------------------------------------------------------------
Center Communication Systems GmbH
A-1210 Wien, Ignaz-Köck-Straße 19
Sitz in Wien
FN 796 88p, Firmenbuchgericht Wien
www.centersystems.com
Tel.: +43 (0) 190 199 - 3616
Mobile: +43 (0) 664 884 75916
Fax: +43 (0) 190 199 - 2110
E-Mail: a.wehrmann_at_[hidden]

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