【发布时间】:2021-11-03 10:12:11
【问题描述】:
我需要安装 cpr,一个 c++ 库,但给我一些错误。
我试图包含从 github 下载的文件夹,但是当我尝试运行代码时,它给了我一个错误:
main.cpp:2:10: fatal error: cpr/cpr.h: No such file or directory
2 | #include <cpr/cpr.h>
| ^~~~~~~~~~~
compilation terminated.
我的代码:
#include <iostream>
#include <cpr/cpr.h>
using namespace std;
int main() {
cpr::Response r = cpr::Get(cpr::Url{"http://www.httpbin.org/get"},
cpr::Parameters{{"hello", "world"}});
cout << r.url << std::endl; // http://www.httpbin.org/get?hello=world
cout << r.text << std::endl;
return 0;
}
项目文件夹:
C:.
├───.vscode
└───cpr
├───.github
│ └───workflows
├───cmake
├───cpr
│ └───CMakeFiles
│ └───3.21.2
├───include
│ └───cpr
└───test
└───data
Visual Studio 代码通知我这个错误:
#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (C:\Users\Bl4ckdestinyXX\Desktop\testcpp\main.cpp).
cannot open source file "curl/curlver.h" (dependency of "cpr/cpr.h")
我该如何解决?
PS:我是 C++ 新手
提前致谢
【问题讨论】:
标签: c++ httprequest httpwebrequest