gpt4 book ai didi

c++ - 编译cpp-netlib v0.9时 Unresolved external symbol 错误

转载 作者:行者123 更新时间:2023-11-30 03:06:24 25 4
gpt4 key购买 nike

我正在尝试构建 cpp-netlib来自 Visual Studio 2010 的库,但出现以下链接器错误:

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)

一点点挖掘发现这可能与我使用的 Boost 版本 (1.46.1) 有关,但我尝试针对 1.47.0 和 1.45.0 进行编译并得到相同的错误。

编译这个库需要什么?

最佳答案

经过大量搜索,我找到了 this发布和this一个来自库的创建者,提到:

  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.

如果我像这样在我的 cpp-netlib header 之前添加该宏定义,我就可以编译:

#define BOOST_NETWORK_NO_LIB

#include <boost/network/protocol/http/client.hpp>

在我发现的第二篇文章中,还提到了“您需要针对 uri 库构建/链接”,这听起来可能是更好的解决方案。

不幸的是,我对 C++ 和 boost 的了解不是最好的,所以我只是选择了有效的方法。

欢迎任何更好的方法,尽管我真正想做的只是编译库,以便我可以评估它的实际使用情况,所以我现在很高兴。

关于c++ - 编译cpp-netlib v0.9时 Unresolved external symbol 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6706586/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com