sudo apt-get install curl-devel
sudo apt-get install libcurl-dev
(will install the default alternative)
OR
sudo apt-get install libcurl4-openssl-dev
(the OpenSSL variant)
OR
sudo apt-get install libcurl4-gnutls-dev
(the gnutls variant)
Answer from n.m.is-an-unemployed-ai-agent on Stack Overflowsudo apt-get install curl-devel
sudo apt-get install libcurl-dev
(will install the default alternative)
OR
sudo apt-get install libcurl4-openssl-dev
(the OpenSSL variant)
OR
sudo apt-get install libcurl4-gnutls-dev
(the gnutls variant)
To those who use centos and have stumbled upon this post :
$ yum install curl-devel
and when compiling your program example.cpp, link to the curl library:
$ g++ example.cpp -lcurl -o example
"-o example" creates the executable example instead of the default a.out.
The next line runs example:
$ ./example
edit: couldnt edit the title but i was basically trying to say why is my code still not compiling even though ive added in the libraries (at least to my knowledge )
starting to play with some APIs in C++ and i have this code right here:
#include <iostream>
#include <string>
#include <stdio.h>
#include <curl/curl.h>
using namespace std;
int main() {
CURL* hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "https://coinranking1.p.rapidapi.com/coins?referenceCurrencyUuid=yhjMzLPhuIDl&timePeriod=24h&tiers%5B0%5D=1&orderBy=marketCap&orderDirection=desc&limit=50&offset=0");
struct curl_slist* headers = NULL;
headers = curl_slist_append(headers, "X-RapidAPI-Key: f9feab3ecfmsh6581fgfd78gfd8p175b11jsn324272c6a0fa");
headers = curl_slist_append(headers, "X-RapidAPI-Host: coinranking1.p.rapidapi.com");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
CURLcode ret = curl_easy_perform(hnd);
}and originally when i tried to compile my code, the problem that i was having was at curl/curl.h.
so i did the following:
-
downloaded curl.h via this link:
-
https://curl.se/download.html
-
-
downloaded the .zip file
-
extracted the .zip file
-
navigated to the include file
-
opened up properties
-
https://imgur.com/a/3vzTOJw
-
-
went to "additional include directories"
-
https://imgur.com/a/COSY8cf
-
-
clicked okay
-
tried rerunning
-
and got the error message :
-
cannot open inclue file curl/curl.h files
-
this is what my filepath looksl ike for my include file :https://imgur.com/a/GGfpGRz
and to confirm these are how my "additional include directories" look like: https://imgur.com/a/C0Et2dq
fatal error: curl/curl.h: No such file or directory
ubuntu - json.cpp:474:23: fatal error: curl/curl.h: No such file or directory - Unix & Linux Stack Exchange
c - Ubuntu - #include <curl/curl.h> no such file or directory - Stack Overflow
[Error] curl/curl.h: No such file or directory
Videos
C compilers' (preprocessors', actually) standard include file searching paths should include /usr/include, therefore if the include file curl.h is located in /usr/include/curl/ and is included by #include <curl/curl.h>, C compilers, such as gcc, should be able to find it without any problem.
However, you are using a toolchain under /opt/toolchains/arm-2011.V2/bin, I guess it is a cross-compiling toolchain. In this case, you cannot use the curl library, because which is for the host system, which probably is a x86 or x86_64 system.
To use curl library in your ARM project, you need to install the curl library development package for ARM, if that is possible. If the software repositories do not have those packages, then you need to download the source code and cross-compile it for ARM first.
This fixed it for me:
sudo ln -s /usr/include/x86_64-linux-gnu/curl /usr/include/curl
Whenever I try to run any program with that library (C++), it always ends up with that error. I was searching for a solution for about an hour, here too, but no answers.
Also yes I checked and I have that library installed on my pc. Version 8.4.0