Boost logo

Boost Users :

Subject: Re: [Boost-users] Asio does not compile
From: Alessandro Candini (candini_at_[hidden])
Date: 2011-08-30 06:22:07


On 30/08/11 12:07, Thomas Heller wrote:
> 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 mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
You are right!
With the following compilation line, it compiles and links like a charm:

g++ -Wall -pedantic -pthread -lboost_system -o timer1 timer1.cpp

Thank you!

-- 
Alessandro Candini
MEEO S.r.l.
Via Saragat 9
I-44122 Ferrara, Italy
Tel: +39 0532 1861501
Fax: +39 0532 1861637
http://www.meeo.it
========================================
"ATTENZIONE:le informazioni contenute in questo messaggio sono
da considerarsi confidenziali ed il loro utilizzo è riservato unicamente
al destinatario sopra indicato. Chi dovesse ricevere questo messaggio
per errore è tenuto ad informare il mittente ed a rimuoverlo
definitivamente da ogni supporto elettronico o cartaceo."
"WARNING:This message contains confidential and/or proprietary
information which may be subject to privilege or immunity and which
is intended for use of its addressee only. Should you receive this
message in error, you are kindly requested to inform the sender and
to definitively remove it from any paper or electronic format."

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