vs2010编译curl为static库及测试

时间:2022-03-16 21:02:56

1,编译curl为static库

  • 用vs2010打开: curl-7.32.0\vs\vc6\vc6curl.dsw
  • 选择LIB Release生成libcurl静态库: curl-7.32.0\vs\vc6\lib\lib-release\libcurl.lib

vs2010编译curl为static库及测试

2,重新建立一个testcurl控制台程序

  • 添加curl头文件:拷贝curl-7.32.0\include\curl  到 testcurl\testcurl 目录下
  • 拷贝libcrul.lib静态库:拷贝curl-7.32.0\vs\vc6\lib\lib-release\libcurl.lib 到testcurl\testcurl 目录下
  • 添加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