Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install Curl in Dev C++ [closed]

Tags:

c++

dev-c++

Hi I'm trying to install Curl : http://curl.haxx.se/download.html , Dev C++ and so far not achieved, could someone explain how to install Curl in Dev C++?

like image 924
Matt Olsen Avatar asked Jul 25 '15 16:07

Matt Olsen


People also ask

How do I add curl to path?

Select the "Path" variable in System Variables, and click Edit. In the Edit environment variable dialog box, click New and add the path to the curl.exe file. Example: C:\curl. Keep clicking OK to accept the change and close the dialog box.


1 Answers

First copy ..\curl-7.40.0-devel-mingw64\include folder from downloaded package into C:\Dev-Cpp\MinGW64\include then copy libraries file (.o,.a,.lib) that are inside ..\curl-7.40.0-devel-mingw64\lib64 folder into C:\Dev-Cpp\MinGW64\lib then compile very first program , don't forget to link libcurl.a :

#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://google.com");
       /* example.com is redirected, so we tell libcurl to follow redirection */
       curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);

       /* 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;
 }

I am using Dev-c++ 5.11 (gcc 4.9.2) and curl-7.40.0-devel-mingw64.

like image 189
udit043 Avatar answered Oct 16 '22 16:10

udit043