1

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?

David Hall
  • 32,624
  • 10
  • 90
  • 127

1 Answers1

3

After a lot of searching I found this post and this one from the creator of the library, mentioning:

  1. 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.

David Hall
  • 32,624
  • 10
  • 90
  • 127
  • I don't see how this is a Boost problem. And I can't find a reference to your mention that Dean says it's a Boost problem. Since cpp-netlib is *not* a Boost Library it seems there's no possible way that building it is a Boost problem! If building it doesn't work it would seem that it's a problem with cpp-netlib, or its documentation. – GrafikRobot Jul 15 '11 at 13:00
  • @GrafikRobot you are right - in one of the posts I linked to Dean says: "Sorry about that, but this will not be fixed as this is a breakage in the Boost.Spirit implementation. Hopefully it works with 1.47 but in the meantime please use cpp-netlib with Boost 1.45.0 instead." so he believes the he ran into a breaking change - but I think he was actually referring to another issue anyway. Ultimately the problem lies with the cpp-netlib documentation, which I've personally found hard to use, which is a shame because this looks like the best (if not only) c++ http lib using boost. – David Hall Jul 15 '11 at 13:09
  • @GrafikRobot and actually, I was reading a third post where I found that quote: https://groups.google.com/group/cpp-netlib/browse_thread/thread/08c9541e6259e8cf# which is entirely unrelated. Will remove those comments (there weren't really intended as criticism of anyone, just pointers to other people running into the same issue, but they were inacurate). – David Hall Jul 15 '11 at 13:11
  • These kinds of issues is why Boost Has a review process and usually long integration process. It hammers out documentation, and build problems. – GrafikRobot Jul 15 '11 at 18:36