Boost logo

Boost Users :

Subject: [Boost-users] using asio.hpp - boost::system::generic_category()
From: Hermann Norpois (hnorpois_at_[hidden])
Date: 2016-09-04 05:12:06


Hello,

I just started with boost and it is obvious that I do not understand give
my compiler (not mentioning code::blocks) the correct instructions.

I installed boost_1_61_0 on Ubuntu 14.04 and followed the instruction. So I
did (as root after sudo -i) in the directory of boost_1_61_0.
I use g++4.9. It was the same with g++4.8.

1) ./bootstrap.sh prefix=/usr/local

2) ./b2 install

So the libs are: /usr/local/lib

The headers: /usr/include/boost

Actually I was interested in some stuff with asio. So I started with
this code from the tutorial.
http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/tutorial/tutdaytime1/src.html

 g++ -Wall main.cpp -o zclient
/tmp/ccxx7PrW.o: In Funktion
`__static_initialization_and_destruction_0(int, int)':
main.cpp:(.text+0x52e): Nicht definierter Verweis auf
`boost::system::generic_category()'
main.cpp:(.text+0x53a): Nicht definierter Verweis auf
`boost::system::generic_category()'
main.cpp:(.text+0x546): Nicht definierter Verweis auf
`boost::system::system_category()'
/tmp/ccxx7PrW.o: In Funktion `boost::system::error_code::error_code()':
main.cpp:(.text._ZN5boost6system10error_codeC2Ev[_ZN5boost6system10error_codeC5Ev]+0x17):
Nicht definierter Verweis auf `boost::system::system_category()'
/tmp/ccxx7PrW.o: In Funktion `boost::asio::error::get_system_category()':
main.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[_ZN5boost4asio5error19get_system_categoryEv]+0x5):
Nicht definierter Verweis auf `boost::system::system_category()'
/tmp/ccxx7PrW.o: In Funktion
`boost::asio::detail::posix_thread::~posix_thread()':
main.cpp:(.text._ZN5boost4asio6detail12posix_threadD2Ev[_ZN5boost4asio6detail12posix_threadD5Ev]+0x26):
Nicht definierter Verweis auf `pthread_detach'
/tmp/ccxx7PrW.o: In Funktion `boost::asio::detail::posix_thread::join()':
main.cpp:(.text._ZN5boost4asio6detail12posix_thread4joinEv[_ZN5boost4asio6detail12posix_thread4joinEv]+0x2b):
Nicht definierter Verweis auf `pthread_join'
/tmp/ccxx7PrW.o: In Funktion
`boost::asio::detail::posix_thread::start_thread(boost::asio::detail::posix_thread::func_base*)':
main.cpp:(.text._ZN5boost4asio6detail12posix_thread12start_threadEPNS2_9func_baseE[_ZN5boost4asio6detail12posix_thread12start_threadEPNS2_9func_baseE]+0x29):
Nicht definierter Verweis auf `pthread_create'
collect2: error: ld returned 1 exit status

I have to add that the simple programm in the starting guide worked properly
http://www.boost.org/doc/libs/1_61_0/more/getting_started/unix-variants.html#link-your-program-to-a-boost-library

via
g++ -Wall main.cpp -o zu

It worked in Code::Blocks as well (without any additional information).

Even the second simple programm (same link) I managed to compile
giving the full path:
g++ -Wall main.cpp -o extractmail /usr/local/lib/libboost_regex.a

At no time I had not to instruct the compiler about the headers. I was
wondering. So it must have anything to do with the libs.

Coming back to my asio- example. Do I need libs for it? I guess is has
something to do with the expression -lboost_system. I used it without
understanding it. But it did not help.

Actually I would appreciate if was able to use Code::Blocks but I did
not manage to give Code::Blocks the correct instructions. I

found some hints, at least amounts of hints ... But it did not work at all.

If somebody is able to explain it (for idiots) ... This would be great.

Thanks

Hermann



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