Quantcast

Noob question - undefined reference to boost::system::get_system_category

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Noob question - undefined reference to boost::system::get_system_category

mx270a
I'm a relatively new to programming on Linux, previous experience was with VB.net in Windows. I'm trying to make the switch to C++, but I'm having a difficult time. I started to follow one of the basic tutorials for Boost ASIO, but I can't get it to compile with the ASIO.hpp file included. The environment is Kubuntu 9.04 and Kdevelop 3.5.3.


Code:
----------------
#include <boost/asio.hpp>

int main()
{
  return 0;
}
----------------


Compile Messages and Errors:
----------------
cd '/home/lance/TS1/debug' && WANT_AUTOCONF_2_5="1" WANT_AUTOMAKE_1_6="1" LC_MESSAGES="C" LC_CTYPE="C" make -k
make all-recursive
Making all in src
compiling ts1.cpp (g++)
mv -f .deps/ts1.Tpo .deps/ts1.Po
linking ts1 (g++)
linking ts1 (g++)
ts1.o: In function `__static_initialization_and_destruction_0':
/usr/include/boost/system/error_code.hpp:205: undefined reference to `boost::system::get_system_category()'
/usr/include/boost/system/error_code.hpp:206: undefined reference to `boost::system::get_generic_category()'
/usr/include/boost/system/error_code.hpp:211: undefined reference to `boost::system::get_generic_category()'
/usr/include/boost/system/error_code.hpp:212: undefined reference to `boost::system::get_generic_category()'
/usr/include/boost/system/error_code.hpp:213: undefined reference to `boost::system::get_system_category()'
ts1.o: In function `boost::asio::error::get_system_category()':
/usr/include/boost/asio/error.hpp:218: undefined reference to `boost::system::get_system_category()'
ts1.o: In function `posix_tss_ptr':
/usr/include/boost/asio/detail/posix_tss_ptr.hpp:47: undefined reference to `pthread_key_create'
ts1.o: In function `~posix_tss_ptr':
/usr/include/boost/asio/detail/posix_tss_ptr.hpp:61: undefined reference to `pthread_key_delete'
collect2: ld returned 1 exit status
make[2]: *** [ts1] Error 1
make[2]: Target `all' not remade because of errors.
make[2]: Nothing to be done for `all-am'.
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
*** Exited with status: 2 ***
----------------


How do I resolve the boost::system errors?

Thanks,
Lance
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Noob question - undefined reference to boost::system::get_system_category

Steven Watanabe-4
AMDG

mx270a wrote:

> I'm a relatively new to programming on Linux, previous experience was with
> VB.net in Windows. I'm trying to make the switch to C++, but I'm having a
> difficult time. I started to follow one of the basic tutorials for Boost
> ASIO, but I can't get it to compile with the ASIO.hpp file included. The
> environment is Kubuntu 9.04 and Kdevelop 3.5.3.
>
>
> Code:
> ----------------
> #include <boost/asio.hpp>
>
> int main()
> {
>   return 0;
> }
> ----------------
>
>
> Compile Messages and Errors:
> <snip>
> /usr/include/boost/system/error_code.hpp:205: undefined reference to
> `boost::system::get_system_category()'

You'll need to follow the instructions at
http://tinyurl.com/ypdqsh
and build the boost system library.

In Christ,
Steven Watanabe

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Noob question - undefined reference to boost::system::get_system_category

Michael Caisse-2
In reply to this post by mx270a
mx270a wrote:

> ts1.o: In function `__static_initialization_and_destruction_0':
> /usr/include/boost/system/error_code.hpp:205: undefined reference to
> `boost::system::get_system_category()'
>
>
>
> How do I resolve the boost::system errors?
>
> Thanks,
> Lance
>  

Lance -

You need to link against the boost system library also.


Michael

--

----------------------------------
Michael Caisse
Object Modeling Designs
www.objectmodelingdesigns.com


_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Noob question - undefined reference to boost::system::get_system_category

mx270a
Michael Caisse-2 wrote
You need to link against the boost system library also.
How do I do that? I tried adding #include <boost/system.hpp> to the program, but there is no file by that name.

-Lance
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Noob question - undefined reference to boost::system::get_system_category

Michael Caisse-2
mx270a wrote:

> Michael Caisse-2 wrote:
>  
>> You need to link against the boost system library also.
>>
>>    
>
> How do I do that? I tried adding #include <boost/system.hpp> to the program,
> but there is no file by that name.
>
> -Lance
>  

Lance -

You need to *link* the system library. For example, it might be called
libboost_system-gcc43-mt-1_37.so.

See Steven's response which pointed you toward the Getting Started guide.

Michael

--

----------------------------------
Michael Caisse
Object Modeling Designs
www.objectmodelingdesigns.com


_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Noob question - undefined reference to boost::system::get_system_category

Igor R.
> You need to *link* the system library. For example, it might be called
> libboost_system-gcc43-mt-1_37.so.
>
> See Steven's response which pointed you toward the Getting Started guide.
>

Alternatively it's possible to use the non-boost asio, which is header-only:
http://blog.think-async.com/2008/05/boostasio-vs-asio.html
_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Loading...