user1462040 user1462040 -3 years ago 197
C++ Question

How to link against cpp-netlib

I would like to use the Library cpp-netlib for a C++ project. Therefore I installed the boost library with the help of homebrew (OS is Mac OS X 10.8). Then I downloaded cpp-netlib from the projects homepage, used cmake to create the Makefile for g++ and successfully applied make.
"make test" passed all its tests. Then I copied the include folder of cpp-netlib into the boost directory.

So here is when the trouble began:
I tried to compile the documentation's first example http-client but couldn't get it to work. When I used

g++ test.cpp -o out -I/usr/local/Cellar/boost/1.53.0/include
-lboost_system-mt -lboost_filesystem-mt -lboost_thread-mt

I received these linker errors:

Undefined symbols for architecture x86_64:
"boost::network::uri::detail::parse(__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::network::uri::detail::uri_parts<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&)", referenced from:
boost::network::uri::uri::parse() in ccs87Dq3.o
"boost::network::http::impl::normal_delegate::normal_delegate(boost::asio::io_service&)", referenced from:
boost::network::http::impl::connection_delegate_factory<boost::network::http::tags::http_async_8bit_udp_resolve>::new_connection_delegate(boost::asio::io_service&, bool, boost::optional<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::optional<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >)in ccs87Dq3.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

I really used the search function but I couldn't find any solution for my problem. What am I doing wrong?

Thanks a lot!

Answer Source

After building cpp-netlib (>=0.9.3) there should 3 static libraries:


When building your http-client project, you should specify a library path for cpp-netlib (-L) and libraries to link (-l) against: cppnetlib-uri and libcppnetlib-client-connections.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download