windows下
一、下载curl
http://download.csdn.net/detail/qq_28234213/9902997
二、配置vs
1.添加包含头文件的目录
属性–>C/C++–>常规–>附加包含目录
加入curl-7.54.1下的include的目录
比如我的是
E:\e-b\homework\天气预报\curl-7.54.1\include
2.添加静态库
a.属性–>链接器–>输入–>附加依赖项 加入
libcurld.lib
3.添加动态库
curl-7.54.1\build\Win32\VC7.1\DLL Debug
下libcurld.lib和libcurld.dll放入工程目录下
三、测试
#include <stdio.h>
#include <curl/curl.h>
#pragma comment(lib,"libcurlb.lib")
int main()
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://www.baidu.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);
}
system("pause");
return 0;
}