c++ - C++ 编译 cpr
问题描述
我正在尝试使用CPR发送 HTTP 请求,但我无法编译它,因此我的应用程序的编译器返回:
1>Send.obj : error LNK2019: symbole externe non résolu "public: __cdecl cpr::Session::Session(void)" (??0Session@cpr@@QEAA@XZ) référencé dans la fonction "class cpr::Response __cdecl cpr::Get<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &&)" (??$Get@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@cpr@@YA?AVResponse@0@$$QEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
在 github 上,没有太多关于如何编译的文档,所以我尝试使用 CMake,但它也返回一个错误:
C++ Requests CMake Options
=======================================================
USE_SYSTEM_CURL: OFF
BUILD_CPR_TESTS: ON
GENERATE_COVERAGE: OFF
CPR_CURL_NOSIGNAL: OFF
USE_SYSTEM_GTEST: OFF
CMAKE_USE_OPENSSL: ON
=======================================================
Not using system Curl, using built-in curl project instead.
CMake Error at opt/CMakeLists.txt:48 (add_subdirectory):
The source directory
D:/Developpement/C++/cpr-master/opt/curl
does not contain a CMakeLists.txt file.
CMake Error at opt/CMakeLists.txt:60 (set_property):
set_property could not find TARGET libcurl. Perhaps it has not yet been
created.
Set CURL_FOUND to TRUE.
Set CURL_LIBRARIES to libcurl.
Set CURL_INCLUDE_DIRS to /include;/include/curl.
Not using system gtest, using built-in googletest project instead.
CMake Error at opt/CMakeLists.txt:82 (add_subdirectory):
The source directory
D:/Developpement/C++/cpr-master/opt/googletest
does not contain a CMakeLists.txt file.
CMake Error at opt/CMakeLists.txt:90 (set_property):
set_property could not find TARGET gtest. Perhaps it has not yet been
created.
CMake Error at opt/CMakeLists.txt:91 (set_property):
set_property could not find TARGET gtest_main. Perhaps it has not yet been
created.
Set GTEST_FOUND to TRUE.
Set GTEST_LIBRARIES to gtest.
Set GTEST_MAIN_LIBRARIES to gtest_main.
Set GTEST_BOTH_LIBRARIES to gtest;gtest_main.
Set GTEST_INCLUDE_DIRS to /include.
Building mongoose project for test support.
CMake Error at opt/CMakeLists.txt:106 (add_subdirectory):
The source directory
D:/Developpement/C++/cpr-master/opt/mongoose
does not contain a CMakeLists.txt file.
Set MONGOOSE_FOUND to TRUE.
Set MONGOOSE_LIBRARIES to mongoose.
Set MONGOOSE_INCLUDE_DIRS to .
CMake Error at opt/CMakeLists.txt:116 (set_property):
set_property could not find TARGET mongoose. Perhaps it has not yet been
created.
Using CURL_INCLUDE_DIRS: /include;/include/curl.
Using CURL_LIBRARIES: libcurl.
Configuring incomplete, errors occurred!
See also "D:/Developpement/C++/cpr-master/build/CMakeFiles/CMakeOutput.log".
See also "D:/Developpement/C++/cpr-master/build/CMakeFiles/CMakeError.log".
我也尝试使用 gcc,但他们没有说明我们必须包含哪些文件,并且它返回无论如何都找不到标头。有人可以描述重现编译 CPR 的步骤吗?或者另一种发送 HTTP 请求的简单方法?谢谢
解决方案
使用git clone --recursive https://github.com/whoshuu/cpr/
代替git clone https://github.com/whoshuu/cpr/
推荐阅读
- python - 如何将多轨迹图制作为可重用代码?
- php - Laravel SESSION 过期 419 并自动重定向
- python - 将python变量传递给tcl
- jquery - 如何使用 wordpress 在 DOM 中附加回调函数
- filenet-p8 - 在 FileNet P8 中更新 Creator 属性
- php - 我们可以在 CodeIgniter 的会话中存储二维数组吗
- flutter - Dart、Flutter Redux Thunk 单元测试
- php - 在 docker compose 中打开 php.ini 添加扩展
- python - 用于单词数据的 CRNN 模型在 932 个训练图像上经过 10 个 epoch 后没有学习任何东西
- node.js - 带有return语句的nodejs异步函数