在Dev C++中安装Curl

8

你好,我正在尝试安装Curl:http://curl.haxx.se/download.html ,还有Dev C++,但是迄今为止没有成功,有人能解释一下如何在Dev C++中安装Curl吗?


你好,请提供一下你尝试过什么以及安装失败的具体细节,谢谢。 - x squared
1
Dev C++是一个集成开发环境。你可能需要先安装cURL,然后告诉Dev C++去安装目录查找,我想。 - Mats Petersson
哪个Dev-C++版本? - udit043
1个回答

7

首先从下载的包中复制 ..\curl-7.40.0-devel-mingw64\include 文件夹到 C:\Dev-Cpp\MinGW64\include,然后将位于 ..\curl-7.40.0-devel-mingw64\lib64 文件夹内的 库文件(.o,.a,.lib) 复制到 C:\Dev-Cpp\MinGW64\lib,最后编译第一个程序时,不要忘记链接 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;
 }

我使用的是Dev-c++ 5.11 (gcc 4.9.2)curl-7.40.0-devel-mingw64


1
很好,感谢您的帮助。如果有人代码失败,您需要将以下内容添加到链接器dll“libcurldll.a”中。 - Matt Olsen

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接