Curl.h no such file or directory

I installed curl this command (I use Ubuntu):

sudo apt-get install curl 

When I test a simple program using g++ test.cpp

 #include <stdio.h> #include <curl/curl.h> int main(void) { CURL *curl; CURLcode res; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "http://example.com"); /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); /* Check for errors */ if(res != CURLE_OK) fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); /* always cleanup */ curl_easy_cleanup(curl); } return 0; } 

g++ shows me:

 fatal error: curl/curl.h: No such file or directory compilation terminated. 

Can anybody help me?

+57
c ++ curl
Jul 13 2018-12-12T00:
source share
5 answers

sudo apt-get install curl-devel

 sudo apt-get install libcurl-dev 

(will set the default alternative)

OR

 sudo apt-get install libcurl4-openssl-dev 

(OpenSSL option)

OR

 sudo apt-get install libcurl4-gnutls-dev 

(gnutls option)

+114
Jul 13 2018-12-12T00:
source share

Those using centos and stumbled upon this post:

  $ yum install curl-devel 

and when compiling your program example.cpp , a link to the curl library:

  $ g++ example.cpp -lcurl -o example 

" -o example " creates an executable example instead of a.out by default.

The following line launches example :

  $ ./example 
+25
Apr 25 '16 at 5:56 on
source share

Instead of loading curl, down libcurl.

curl is just an application, libcurl is what you need for your C ++ program

http://packages.ubuntu.com/quantal/curl

+4
Jul 13 2018-12-12T00:
source share

yes, please download curl-devel as above. also do not forget to refer to lib curl:

 -L/path/of/curl/lib/libcurl.a (g++) 

amuses

+3
Jul 13 '12 at 13:50
source share

If after installation curl-dev luarocks does not see the headers:

 find /usr -name 'curl.h' Example: /usr/include/x86_64-linux-gnu/curl/curl.h luarocks install lua-cURL CURL_INCDIR=/usr/include/x86_64-linux-gnu/ 
+1
Mar 18 '19 at 13:06
source share



All Articles