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
[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++ - Getting error: fatal error: curl/curl.h: No such file or directory #include <curl/curl.h> - Stack Overflow
[BUG] curl/curl.h: No such file or directory
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
Mingw is gcc for windows. Practically everything that applies to gcc applies to mingw.
It's better to use relative paths in your Makefile and with gnu make (which is part of mingw/msys) always use '/' as path separator. If you have to use absolute path like C:\dev\projects\mylib use it this way: C:/dev/projects/mylib.
Back to your curl: curl/curl.h is in C:\path\to\curl-7.76.1-win32-mingw\include\curl\curl.h so you need to add include directory to your gcc command line that points to the right directory, which is C:\path\to\curl-7.76.1-win32-mingw\include because you use "curl/curl.h". If you don't have it (that curl) installed system wide it's also better to use "curl/curl.h" in #include path than <curl/curl.h>.
So all you have to do is add -Ipath/to/curl-7.76.1-win32-mingw/include to your compile line, like:
g++ -O2 -Ipath/to/curl-7.76.1-win32-mingw/include -c -omain.o main.cpp
It can be done automatically in Makefile:
CXX = g++
CFLAGS += -O2
INCLUDES += -Ipath/to/curl-7.76.1-win32-mingw/include
.cpp.o:
(CXXFLAGS) $(INCLUDES) $*.cpp
You write:
g++ -I "C:\Program Files\Curl\curl-7.76.1-win32-mingw\include\curl"
try better:
g++ -I "C:\Program Files\Curl\curl-7.76.1-win32-mingw\include"
as you have written in the code sample:
#include <curl/curl.h>
or conserve the -I option as it was, and change your #include to:
#include <curl.h>
I sincerely hope this will help.
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
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
As far as I know (at this date), curl is available from Windows 10 v1803 console (I tested and indeed it is). The detailed explanations are here. For the use of libcurl on windows 10, I could not really find resources
There is no curl precompiled package on other windows. You need to either build libcurl from the sources as explained from this excellent resource and here. I tested these resources and they work.
If you use Visual Studio, the resources also show how you configure Visual studio to use it in your programs but I you also have this on SO (I found this resource on SO: How do you properly install libcurl for use in visual studio 2017?)
I haven't used that API, but I have used C++ APIs with Visual Studio before, assuming that is your IDE. So i was looking at the tutorial suggested above: link
Basically you need to compile either Libcurl or curlcpp given that the API is written in C. The tutorial explains a method for each, but seems to me that the one suggested for Libcurl is easier, given that there's already a Visual Studio solution for it and you only need to do a double click and compile it (this is a guess, I haven't tried).
Then, once you have built the project, you'll get a folder with files, DLLs and LIB files. The tutorial only says to declare those directories in your project:
Add CURL_STATICLIB to the preprocessor definitions.
Add curl\include and curlcpp\include to the list of Additional Include Directories. (Make sure you include the correct relative paths.)
Add curl and curlcpp output folders, curl\build\lib\x86 and curlcpp\lib\x86\, to the Additional Library Directories.
Add the following static libraries to the list of Additional dependencies: libcurld.lib;curlcppd.lib;Crypt32.lib;ws2_32.lib;winmm.lib;wldap32.lib;
This mean, you need to open the Properties of your solution (Right click, Properties), and add the folders required to tell Visual Studio that you have header files outside the typical installation folders.
In the Properties page, Under Configuration Properties, you'll see a property called VC++ Include Directories, in the Include Directories option is where you have to add the paths for the curl\include and curlcpp\include to let VS know that you have headers there.
Navigate thru the Properties page and you'll find the option for all of those steps above, The Include Directory and Library Directory are under the VC++ Directories property, and the Additional Library Directory is under the Linker Properties.
You have the curl/ directory in the source code, but also in the option.
It seems the option should point out the higher-level directory in which curl/ is, so it should be something like:
Copy-I/local/include/
I think the problem is likely that you give your include paths on the command line in the Win32 path format. This is not the same as the one used by msys (or ultimately Cygwin).
Try these:
Copy$ gcc -I/include/
-I/local/include/curl
-I/local/lib/pkgconfig
...
Hope I got the absolut paths right, but you can check in your msys shell.
What ticked me off was that you use ./config, which wouldn't work from the Command Prompt, but works from the msys shell. So you need to give paths that all the programs in MinGW understand.
Basically, most programs in MinGW only have the concept of a single file system root, like on any unixoid system, while Win32 has multiple (the drive letters). Since the MinGW programs are linked accordingly, you need to give paths that they understand.