0

I'm trying to understand how to run http commands in C++ so I can send requests to an API online and receive a Json response. However, I can't even begin to understand how this works, or what to do. I know I have curl installed on my PC (Windows 10), I checked, and it's there. But... I don't understand how to connect that to Visual Studio? I see a lot of people writing code with

#Include <"curl/curl.h">

I have no idea where this library exists on my PC, where to find it, how to integrate it, etc. Can anyone please help me?

I also see a lot of people using bash? But that's a linux thing, I don't have Linux and have no idea how it works. I'd appreciate just a basic explanation of how to get curl to work with cpp, because I've scoured the internet relentlessly, curlpp doesn't work, libcurl requires tools I don't have and don't fathom, and frankly... It feels like a nightmare of complication for something that should be, on surface level, relatively simple?

Thank you in advance for anyone who could take the time to help me with this.

  • You have to tell VS where to look... also, the code snippet you posted isn't valid C++ – ChrisMM May 04 '22 at 13:12
  • curl is just a cli-tool. you should be able to use it with the windows command line exactly like bash. – Eric May 04 '22 at 13:13
  • 1
    Also, it's `#include`, with a lowercase 'I'. There's a lot to unwrap in this question. You need to have one question. People can talk about installing libraries, activating WSL (that should have been easily searchable, though), configuring VS, etc. – sweenish May 04 '22 at 13:16
  • If you don't want to use libcurl, you can also use [WinHTTP](https://learn.microsoft.com/en-us/windows/win32/winhttp/about-winhttp) or [WhenINet](https://learn.microsoft.com/en-us/windows/win32/wininet/portal) when you are using Microsoft Windows. However, that means that your code will be limited to Microsoft Windows and won't run on other platforms, such as Linux. – Andreas Wenzel May 04 '22 at 13:18
  • 1
    The name `curl` refers to the command-line utility, which can be called from `bash` on Linux or `cmd.exe` on Microsoft Windows. The name of the library used by `curl` is called `libcurl`, which you can use yourself in your C++ programs. Although it is possible to call `curl` directly from your C++ programs, it is usually recommended that you use `libcurl` instead. The program `curl` is intended to be called directly by the user or from bash scripts. – Andreas Wenzel May 04 '22 at 13:21

0 Answers0