Visual Studio 2017中cpprestapi的问题找不到POST / GET常量

时间:2018-09-11 00:49:52

标签: c++ cpprest-sdk vcpkg

在API客户端中具有代码

   #include "cpprest/http_msg.h"

    ...

    http_request req;
    req.set_method(web::http::methods::POST);

    ...

链接期间有消息:

  

1> client.obj:错误LNK2001:无法解析的外部符号“ public:   静态类std :: basic_string,类std :: allocator> const   web :: http :: methods :: GET“   (?GET @ methods @ http @ web @@ 2V?$ basic_string @ _WU?$ char_traits @ _W @ std @@ V?$ allocator @ _W @ 2 @@ std @@ B)

     

1> client.obj:错误LNK2001:无法解析的外部符号“ public:   静态类std :: basic_string,类std :: allocator> const   web :: http :: methods :: POST“   (?POST @ methods @ http @ web @@ 2V?$ basic_string @ _WU?$ char_traits @ _W @ std @@ V?$ allocator @ _W @ 2 @@ std @@ B)

当删除行req.set_method(web :: http :: methods :: POST)时,它消失了; 据我了解web :: http :: methods :: POST是常量,因此必须在client.obj中构建。还不明白。

这是静态链接。 basic_string可能存在的问题

1 个答案:

答案 0 :(得分:0)

vcpkg为静态和动态linckink构建cpprest。两者的问题名称均相同。因此,它尝试使用动态库而不是静态库。

重命名了额外的库-已构建项目。我认为VCPKG必须具有对Swich库进行调查的选项。