libcurl 7.69.1 编译配置 (VS2017)

一、环境:

      VS2017 、 libcurl 7.69.1

二、开始编译

   1.打开VS2017 的命令行工具

     2.进入 curl7.69.1/winbuild

执行编译

nmake /f makefile.vc mode=static vc=15 debug=no machine=x86 ENABLE_IDN=no

编译参数请参考 BUILD.WINDOWS.txt 我这里用的 vs2017 静态编译,release x86版本.

三、配置项目

配置属性-》VC++目录-》包含目录-》

    添加:

F:\curl-7.69.1\builds\libcurl-vc15-x86-release-static-ipv6-sspi-winssl\include

配置属性-》C/C++预处理器-》预处理器定义

   添加:

CURL_STATICLIB

配置属性-》链接器-》常规-》附加库目录

  添加 

F:\curl-7.69.1\builds\libcurl-vc15-x86-release-static-ipv6-sspi-winssl\lib

配置属性-》链接器-》输入-》附加依赖项

  添加 

libcurl_a.lib
ws2_32.lib
winmm.lib
wldap32.lib
crypt32.lib

四:HelloWorld

#include      
int main(int argc, char* argv[]) {
	CURL *curl = 0;
	CURLcode res;
	curl = curl_easy_init();
	if (curl != 0) {
		curl_easy_setopt(curl, CURLOPT_URL, "http://www.qq.com"); 
		curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); 
		res = curl_easy_perform(curl); 
		if (res != CURLE_OK) {
			fprintf(stderr, "curl_easy_perform() failed err mesg: %s\n", curl_easy_strerror(res));
		} 
		curl_easy_cleanup(curl);
	}
	return 0;
}

 

你可能感兴趣的:(C++)