1. 首先编译openssl静态库

整个过程用的是 vs2015命令提示工具

需要安装perl
下载地址:添加链接描述
解压后, 在 openssl-1.0.2e目录下创建develop这个文件夹, cd到 openssl-1.0.2e目录下,

a.配置编译文件和模式
执行

perl Configure VC-WIN32 no-asm --prefix=E:\curl\openssl-1.0.2e\develop

VC-WIN32标识windows 32位操作系统,
64位用VC-WIN64A表示, 若要使用debug版本,请使用debug-VC-WIN64A或debug-VC-WIN32
no-asm 表示不用汇编
–prefix=E:\curl\openssl-1.0.2e\develop 是设置安装目录
b.生成编译配置文件
若为Windows 64位系统,执行

ms\do_win64a.bat

若为Windows 32位系统,执行

ms\do_ms.bat

执行这一步之后,在ms目录下会生成nt.mak和ntdll.mak两个编译配置文件
nt.mak 用于生成静态lib库
ntdll.mak 用于生成动态dll库
c.编译
静态库

nmake -f ms\nt.mak

动态库

nmake -f ms\ntdll.mak

d.测试
测试静态库:

 nmake -f ms\nt.mak test

测试动态库:

 nmake -f ms\ntdll.mak test

若最终显示 passed all tests 则说明生成的库正确
e.安装
安装静态库:

nmake -f ms\nt.mak install

安装动态库:

nmake -f ms\ntdll.mak install

编译安装完成后,会在E:\curl\openssl-1.0.2e\develop目录下看到生成的相关文件夹
f.清楚上次编译
清除上次静态库的编译,以便重新编译:

nmake -f ms\nt.mak clean

清除上次动态库的编译,以便重新编译:

nmake -f ms\ntdll.mak clean

参考:https://blog.csdn.net/mayue_web/article/details/83997969,非常详细

2.编译zlib

a.下载源码
http://zlib.net/zlib-1.2.11.tar.gz
解压后,在zlib根目录下 命令行执行
nmake -f win32/Makefile.msc

3.编译libcurl

a.下载源码
http://curl.haxx.se/download/curl-7.46.0.tar.bz2
b.拷贝所需的openssl与zlib相关库与头文件
.根据curl源代码根目录下winbuild目录下BUILD.WINDOWS.txt的提示
在源代码同级的目录下建立deps文件夹
此时的目录结构如下图(伪目录

somedirectory\
|__curl-src
|    |_winbuild
|
|__deps|_ lib|_ include|_ bin

我这里的deps文件夹目录是 E:\curl\deps
将编译openssl时候,安装目录E:\curl\openssl-1.0.2e\develop\include下的
openssl夹拷贝到E:\curl\deps\include\目录下;
将zlib源码根目录下的zconf.h、zlib.h和zutil.h拷贝到E:\curl\deps\include目录下。
将E:\curl\openssl-1.0.2e\develop\lib目录下的libeay32.lib和ssleay.lib拷贝到E:\curl\deps\lib目录下;
将zlib源码根目录下的zlib.lib拷贝到E:\curl\deps\lib目录下。
c.编译libcurl
命令行进入源代码根目录下 winbuild 目录

nmake RTLIBCFG=static /f Makefile.vc mode=static VC=14 WITH_DEVEL=E:\curl\deps WITH_SSL=static ENABLE_SSPI=no ENABLE_IPV6=no DEBUG=no

参数详细含义如下:

nmake /f Makefile.vc mode=<static or dll> <options>where <options> is one or many of:VC=<6,7,8,9,10,11,12,14>     - VC versionsWITH_DEVEL=<path>            - Paths for the development files (SSL, zlib, etc.)Defaults to sibbling directory deps: ../depsLibraries can be fetched at http://windows.php.net/downloads/php-sdk/deps/Uncompress them into the deps folder.WITH_SSL=<dll or static>     - Enable OpenSSL support, DLL or staticWITH_CARES=<dll or static>   - Enable c-ares support, DLL or staticWITH_ZLIB=<dll or static>    - Enable zlib support, DLL or staticWITH_SSH2=<dll or static>    - Enable libSSH2 support, DLL or staticENABLE_SSPI=<yes or no>      - Enable SSPI support, defaults to yesENABLE_IPV6=<yes or no>      - Enable IPv6, defaults to yesENABLE_IDN=<yes or no>       - Enable use of Windows IDN APIs, defaults to yesRequires Windows Vista or later, or installation from:http://www.microsoft.com/downloads/details.aspx?FamilyID=AD6158D7-DDBA-416A-9109-07607425A815ENABLE_WINSSL=<yes or no>    - Enable native Windows SSL support, defaults to yesGEN_PDB=<yes or no>          - Generate Program Database (debug symbols for release build)DEBUG=<yes or no>            - Debug buildsMACHINE=<x86 or x64>         - Target architecture (default is x86)Static linking of Microsoft's C RunTime (CRT):
==============================================
If you are using mode=static nmake will create and link to the static build of
libcurl but *not* the static CRT. If you must you can force nmake to link in
the static CRT by passing RTLIBCFG=static. Typically you shouldn't use that
option, and nmake will default to the DLL CRT. RTLIBCFG is rarely used and
therefore rarely tested. When passing RTLIBCFG for a configuration that was
already built but not with that option, or if the option was specified
differently, you must destroy the build directory containing the configuration
so that nmake can build it from scratch.Legacy Windows and SSL
======================
When you build curl using the build files in this directory the default SSL
backend will be WinSSL (Windows SSPI, more specifically Schannel), the native
SSL library that comes with the Windows OS. WinSSL in Windows <= XP is not able
to connect to servers that no longer support the legacy handshakes and
algorithms used by those versions. If you will be using curl in one of those
earlier versions of Windows you should choose another SSL backend like OpenSSL.

3.验证

vs2015
添加好包含目录 ,附加库目录, 附加依赖项后,预处理器添加上BUILDING_LIBCURL

// staticLibcurlTest.cpp : 定义控制台应用程序的入口点。
//#include "stdafx.h"
#include <iostream>
#include <curl.h>using namespace std;/**
* 一旦curl接收到数据,就会调用此回调函数
* buffer:数据缓冲区指针
* size:调试阶段总是发现为1
* nmemb:(memory block)代表此次接受的内存块的长度
* userp:用户自定义的一个参数
*/
size_t write_data(void* buffer, size_t size, size_t nmemb, void* userp)
{static int current_index = 0;cout << "current:" << current_index++;cout << (char*)buffer;cout << "---------------" << endl;int temp = *(int*)userp;    // 这里获取用户自定义参数return nmemb;
}int main()
{curl_global_init(CURL_GLOBAL_ALL); // 首先全局初始化CURLCURL* curl = curl_easy_init(); // 初始化CURL句柄if (NULL == curl){return 0;}int my_param = 1;    // 自定义一个用户参数// 设置目标URLcurl_easy_setopt(curl, CURLOPT_URL, "https://api.vxxx/gettime");// 设置接收到HTTP服务器的数据时调用的回调函数curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);// 设置自定义参数(回调函数的第四个参数)curl_easy_setopt(curl, CURLOPT_WRITEDATA, &my_param);// 执行一次URL请求CURLcode res = curl_easy_perform(curl);// 清理干净curl_easy_cleanup(curl);getchar();return 0;
}

参考:
https://blog.csdn.net/fm0517/article/details/91822880
https://blog.csdn.net/huangyimo/article/details/80337496

在windows下,编译可访问https的libcurl静态库过程相关推荐

  1. windows下编译支持https的curl

    先编译好openssl,过程详见:<windows下编译openssl> 编译好zlib,过程详见<windows下编译zlib> 1. 下载curl 官网:https://c ...

  2. Windows下编译Chrome V8

    主要还是参考google的官方文档: How to Download and Build V8 Building on Windows 同时也参考了一些其它的中文博客: 脚本引擎小pk:SpiderM ...

  3. Windows下编译 Hadoop

    Windows下编译 Hadoop-2.9.2 系统环境 系统: Windows 10 10.0_x64 maven: Apache Maven 3.6.0 jdk: jdk_1.8.0_201 Pr ...

  4. Windows下编译tensorflow-gpu教程

    这两个也要看: https://zhuanlan.zhihu.com/p/29029860 https://zhuanlan.zhihu.com/p/34942873 Windows下编译tensor ...

  5. Windows下编译TensorFlow1.3 C++ library及创建一个简单的TensorFlow C++程序

    参考:https://www.cnblogs.com/jliangqiu2016/p/7642471.html Windows下编译TensorFlow1.3 C++ library及创建一个简单的T ...

  6. 在Windows下编译FFmpeg详细说明

    在Windows下编译FFmpeg详细说明 MinGW:一个可自由使用和自由发布的Windows特定头文件和使用GNC工具集导入库的集合,允许你生成本地的Windows程序而不需要第三方C运行时 Mi ...

  7. linux下find查找带有指定权限的文件(windows下编译的源代码文件)

    find -type f -perm -o=x 查找用户在windows下编译的源代码文件 转载于:https://blog.51cto.com/axlrose/1357610

  8. lua windows下编译

    从Lua5.1开始官方给出的文件只有源代码和makefile文件了,官网给出的bulid方式也是在linux平台,如果只是想找个库使用下可以到这里来下载:http://joedf.ahkscript. ...

  9. 在windows下编译FFMPEG-最新2009版本

    转]在windows下编译FFMPEG-最新2009版本 2010-11-17 18:50 大家可以看到,此篇之前有很多个版本的"在windows下编译FFMPEG",那些都是我在 ...

最新文章

  1. 一个数字可以在不损失精度的情况下达到的JavaScript的最高整数值是多少?
  2. opencv orb
  3. MongoDB学习笔记三:查询
  4. 数据结构--顺序栈和链式栈
  5. 这一团糟的代码,真的是我写的?!
  6. 一部刷爆朋友圈的5G短片,看完才知道5G多暖多重要!
  7. oc61--block
  8. ug产品摆正高级技巧_UG8.0工件怎么摆正角度教程?
  9. 【FPGA频率计】基于FPGA的数字频率计开发,VHDL编程实现
  10. Kernel那些事儿之内存管理(6) --- 衣带渐宽终不悔(下)
  11. html查看今天星期几,jquery怎么获取星期几
  12. Bouncing Ball (dp)
  13. 微博【黄金分析师吕超】--2.16黄金分析
  14. 区块链技术在金融行业的应用与风险管理
  15. linux安装java(zz)
  16. MII、RMII、SMII、GMII接口简介
  17. 什么是最好的在线UML软件工具?
  18. STL vector :大理石在哪儿?
  19. JAVA程序员成长之路的总结
  20. docker导出mysql_Docker 导出 mysql 数据

热门文章

  1. Pyechart:30分钟学会pyecharts数据可视化
  2. Illustrator、Indesign与Photoshop
  3. PHP ajax跨域问题最佳解决方案
  4. python—内置函数-字符串,eval,isinstance
  5. MySQL数据库安全配置
  6. 【Kissy WaterFall】实行手动加载数据
  7. 几种流行的JS框架的选择
  8. SQL 分页存储过程(转)
  9. mysql数据库套件_MySQL数据库管理开发套件(EMS SQL Management Studio For MySQL)下载 v1.3.0.46170 官方版 - 比克尔下载...
  10. sap生产工单报工_【案例】MES系统助力亨通电缆车间生产效率提升25%