libcpr / cpr

C++ Requests: Curl for People, a spiritual port of Python Requests.
https://docs.libcpr.org/
Other
6.29k stars 903 forks source link

Building a simple C++ console application after installing libcpr package in Visual Studio 2019 gives multiple errors #986

Closed RajaniNair198 closed 7 months ago

RajaniNair198 commented 7 months ago

Description

I have a REST API in ASP.Net Core, and am trying to use libcpr to build a REST client in C++ so I can invoke HTTP requests to my API. (Iam fairly new to C++). I created a simple console application in C++, installed the package libcpr and added the following basic code to test a simple GET request.

include

include <cpr/cpr.h>

int main() { cpr::Response r = cpr::Get(cpr::Url{ "https://localhost:44310/api/Item" });

std::cout << r.url << std::endl; // https://localhost:44310/
std::cout << r.status_code << std::endl; // 200
std::cout << r.header["content-type"] << std::endl; // application/json
std::cout << r.text << std::endl;

}

Building the solution gives me multiple compilation issues (in the external dependencies files associated with libcpr), as shown in the screenshot attached.

Have I missed including anything? Please help. libcpr_buildErrors

Example/How to Reproduce

  1. Create a console application in C++ (Visual Studio 2019).
  2. Install the package libcpr from Nuget Package Manager.
  3. Add some basic code for a GET request. (as specified in the documentation).
  4. Build the project/solution.
  5. Compilation fails with multiple errors. (screenshot attached).

Possible Fix

No response

Where did you get it from?

GitHub

Additional Context/Your Environment

RajaniNair198 commented 7 months ago

My bad. My project was targeting C++14. When I changed it to C++17, the build succeeded. Thanks.