1,编译curl为static库
- 用vs2010打开: curl-7.32.0vsvc6vc6curl.dsw
- 选择LIB Release生成libcurl静态库: curl-7.32.0vsvc6liblib-releaselibcurl.lib
2,重新建立一个testcurl控制台程序
- 添加curl头文件:拷贝curl-7.32.0includecurl 到 testcurl estcurl 目录下
- 拷贝libcrul.lib静态库:拷贝curl-7.32.0vsvc6liblib-releaselibcurl.lib 到testcurl estcurl 目录下
- 添加CURL_STATICLIB 到 预处理器: Property ->Configuration Properties -> C/C++ ->Preprocessor ->Preprocessor Definitions
- 写入curl测试代码:
#include "stdafx.h" #include <Windows.h> #include "curl/curl.h" #pragma comment(lib, "libcurl.lib") #pragma comment(lib, "wldap32.lib") #pragma comment(lib, "ws2_32.lib") #pragma comment(lib, "winmm.lib") int _tmain(int argc, _TCHAR* argv[]) { CURL *curl; CURLcode res; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "http://2345.com/?kduba"); res = curl_easy_perform(curl); curl_easy_cleanup(curl); } getchar(); return 0; }
http://blog.csdn.net/appletreesujie/article/details/12082795
http://blog.inet198.cn/?appletreesujie/article/details/12082795