I am trying to build the cpp-netlib library from Visual Studio 2010 but get the following linker error:
error LNK2019: unresolved external symbol "bool __cdecl boost::network::uri::detail::parse_uri_impl(class boost::iterator_range,class std::allocator > > &,struct boost::network::uri::detail::uri_parts_default_base &,struct boost::network::tags::default_string)" (?parse_uri_impl@detail@uri@network@boost@@YA_NAAV?$iterator_range@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@4@AAUuri_parts_default_base@1234@Udefault_string@tags@34@@Z) referenced in function "bool __cdecl boost::network::uri::detail::parse_uri,class std::allocator >,struct boost::network::http::tags::http_default_8bit_tcp_resolve>(class std::basic_string,class std::allocator > &,struct boost::network::uri::detail::uri_parts &)" (??$parse_uri@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@Uhttp_default_8bit_tcp_resolve@tags@http@network@boost@@@detail@uri@network@boost@@YA_NAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAU?$uri_parts@Uhttp_default_8bit_tcp_resolve@tags@http@network@boost@@@0123@@Z)
A little bit of digging turned up that this could be related to the version of Boost I'm using (1.46.1) but I have tried compiling against both 1.47.0 and 1.45.0 and get the same error.
What is required to get this library to compile?
After a lot of searching I found this post and this one from the creator of the library, mentioning:
- An option to turn off the required external library to be linked with a macro (BOOST_NETWORK_NO_LIB). With this macro defined before any cpp-netlib headers are included (or on the command line) the functions that were made extern or just free functions at namespace level are marked 'inline' and have their definitions pulled in accordingly in each translation unit. This addresses Jeff Garland's and others' concern of the need for an external library when using cpp-netlib when it's always been header-only until 0.9. I'm still wrestling with the thought of making the header-only behavior a default, but I'm not married to the "external library as default" decision either.
I am able to compile if I add that macro definition before my cpp-netlib headers like so:
#define BOOST_NETWORK_NO_LIB
#include <boost/network/protocol/http/client.hpp>
In the second post I found there is also mention of "You need to build/link against the uri library" which sounds like it might be a better solution.
Unfortunately my knowledge of c++ and boost isn't the best so I just went with what worked.
Any better approaches are welcome, though all I really wanted to do was compile the library so I can evaluate it for real use, so I'm happy right now.