Search code examples
c++compilationcpp-netlib

Error when compiling cpp-netlib source


I have installed the c++ networking library as described in the documentation and I am trying to compile the http client example manually. I am using the 0.11 version of the library.

I am using this command for compilation:

g++ -o http_c     http_client.cpp     -lcppnetlib-uri     -lcppnetlib-server-parsers     -lcppnetlib-client-connections     -lboost_thread     -I/usr/local/include     -L/usr/local/lib64

and I get this error:

In file included from /usr/include/boost/iostreams/detail/is_dereferenceable.hpp:12:0,
                 from /usr/include/boost/iostreams/detail/resolve.hpp:26,
                 from /usr/include/boost/iostreams/detail/push.hpp:24,
                 from /usr/include/boost/iostreams/detail/streambuf/indirect_streambuf.hpp:31,
                 from /usr/include/boost/iostreams/stream_buffer.hpp:22,
                 from /usr/include/boost/iostreams/stream.hpp:21,
                 from /usr/include/boost/spirit/home/qi/stream/detail/iterator_source.hpp:14,
                 from /usr/include/boost/spirit/home/qi/stream/stream.hpp:16,
                 from /usr/include/boost/spirit/home/qi/stream.hpp:15,
                 from /usr/include/boost/spirit/home/qi.hpp:30,
                 from /usr/include/boost/spirit/include/qi.hpp:16,
                 from /usr/local/include/boost/network/uri/accessors.hpp:12,
                 from /usr/local/include/boost/network/uri/uri.hpp:308,
                 from /usr/local/include/boost/network/protocol/http/message/wrappers/uri.hpp:10,
                 from /usr/local/include/boost/network/protocol/http/request.hpp:18,
                 from /usr/local/include/boost/network/protocol/http/client.hpp:13,
                 from http_client.cpp:1:
/usr/include/boost/type_traits/detail/bool_trait_def.hpp:18:79: note: #pragma message: NOTE: Use of this header (bool_trait_def.hpp) is deprecated
 # pragma message("NOTE: Use of this header (bool_trait_def.hpp) is deprecated")
                                                                               ^
In file included from /usr/include/boost/type_traits/detail/bool_trait_def.hpp:21:0,
                 from /usr/include/boost/iostreams/detail/is_dereferenceable.hpp:12,
                 from /usr/include/boost/iostreams/detail/resolve.hpp:26,
                 from /usr/include/boost/iostreams/detail/push.hpp:24,
                 from /usr/include/boost/iostreams/detail/streambuf/indirect_streambuf.hpp:31,
                 from /usr/include/boost/iostreams/stream_buffer.hpp:22,
                 from /usr/include/boost/iostreams/stream.hpp:21,
                 from /usr/include/boost/spirit/home/qi/stream/detail/iterator_source.hpp:14,
                 from /usr/include/boost/spirit/home/qi/stream/stream.hpp:16,
                 from /usr/include/boost/spirit/home/qi/stream.hpp:15,
                 from /usr/include/boost/spirit/home/qi.hpp:30,
                 from /usr/include/boost/spirit/include/qi.hpp:16,
                 from /usr/local/include/boost/network/uri/accessors.hpp:12,
                 from /usr/local/include/boost/network/uri/uri.hpp:308,
                 from /usr/local/include/boost/network/protocol/http/message/wrappers/uri.hpp:10,
                 from /usr/local/include/boost/network/protocol/http/request.hpp:18,
                 from /usr/local/include/boost/network/protocol/http/client.hpp:13,
                 from http_client.cpp:1:
/usr/include/boost/type_traits/detail/template_arity_spec.hpp:13:84: note: #pragma message: NOTE: Use of this header (template_arity_spec.hpp) is deprecated
 # pragma message("NOTE: Use of this header (template_arity_spec.hpp) is deprecated")
                                                                                    ^
In file included from /usr/include/boost/iostreams/detail/is_dereferenceable.hpp:13:0,
                 from /usr/include/boost/iostreams/detail/resolve.hpp:26,
                 from /usr/include/boost/iostreams/detail/push.hpp:24,
                 from /usr/include/boost/iostreams/detail/streambuf/indirect_streambuf.hpp:31,
                 from /usr/include/boost/iostreams/stream_buffer.hpp:22,
                 from /usr/include/boost/iostreams/stream.hpp:21,
                 from /usr/include/boost/spirit/home/qi/stream/detail/iterator_source.hpp:14,
                 from /usr/include/boost/spirit/home/qi/stream/stream.hpp:16,
                 from /usr/include/boost/spirit/home/qi/stream.hpp:15,
                 from /usr/include/boost/spirit/home/qi.hpp:30,
                 from /usr/include/boost/spirit/include/qi.hpp:16,
                 from /usr/local/include/boost/network/uri/accessors.hpp:12,
                 from /usr/local/include/boost/network/uri/uri.hpp:308,
                 from /usr/local/include/boost/network/protocol/http/message/wrappers/uri.hpp:10,
                 from /usr/local/include/boost/network/protocol/http/request.hpp:18,
                 from /usr/local/include/boost/network/protocol/http/client.hpp:13,
                 from http_client.cpp:1:
/usr/include/boost/type_traits/detail/template_arity_spec.hpp:13:84: note: #pragma message: NOTE: Use of this header (template_arity_spec.hpp) is deprecated
 # pragma message("NOTE: Use of this header (template_arity_spec.hpp) is deprecated")
                                                                                    ^
/usr/bin/ld: /tmp/cczusVNF.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv'
/usr/lib/libboost_system.so.1.60.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

I don't know what is happening.


Solution

  • Those boost warnings about deprecated headers can be ignored, they are a known problem with boost 1.60.0.

    That leaves you with the undefined reference to the boost system library. Did you actually install the boost libraries you are using on your system? That may fix your problem. Installation is OS-specific, start here.