开篇提示:本文为本人原创,本文欢迎转载,但必须注明本文出处,例如:
“该文引用自 CruiseYoung的:“ActivePerl、dmake、nasm、nmake编译OpenSSL(1.1.0系列)”
http://blog.csdn.net/fksec/article/details/52667055” 否则说明阁下愿意支付以100元人民币每字计的稿费,敬请留意。
注1:本文基于Win x64位平台来讲解,x86基本相同:
注2:ActivePerl、nasm、nmake编译OpenSSL(1.0.1系列):http://blog.csdn.net/fksec/article/details/25969257
1 下载软件包
1.1 ActivePerl(x64):http://www./activeperl/downloads
1.2 nasm(x64):http://www./
1.3 zlib编译见“nmake、cmake、Visual Studio编译zlib”:http://blog.csdn.net/fksec/article/details/25906419
1.4 OpenSSL:http://www./source/
代码托管地址:https://github.com/openssl/openssl(在Tags中选对应版本进行下载,否则静态版本能编译通过,而动态版本编译不能通过)
2 准备工作
2.1 阅读:
2.1.1 编译方法
README
NOTES.WIN
Configurations\README
Configurations\windows-makefile.tmpl
2.1.2 编译选项
文件INSTALL
--with-zlib-include=DIR
--with-zlib-lib=LIB
zlib
zlib-dynamic
2.1.3 编译配置(方式)
文件INSTALL
注意以下内容:
$ perl d:\PATH\TO\OPENSSL\SOURCE\Configure {{ target }} [[ options ]]
--prefix=OpenSSL
--openssldir=SSL
--with-zlib-include=DIR
--with-zlib-lib=LIB
zlib
zlib-dynamic
--debug
--release (default)
no-shared
no-threads (default)
threads
on Windows (only pick one of the targets for configuration):
$ perl Configure { VC-WIN32 | VC-WIN64A | VC-WIN64I | VC-CE }
$ nmake
$ nmake test
$ nmake install
2.2 编译环境:点击“开始”-->"所有程序"-->"Visual Studio 2013"-->"Visual Studio Tools"-->"VS2013 x64 本机工具命令提示"
2.3 编译前工具安装(openssl-1.1.0系列):
2.3.1 安装nasm,下载链接http://www./
安装后,右击“我的电脑”-->属性-->高级-->环境变量-->系统变量-->path项添加:
D:\Tools\NASM
2.3.2 安装ActivePerl
2.3.2.1 安装ActivePerl
2.3.2.1 安装dmake(必须在联网的情况下),点击“开始”-->"所有程序"-->"Visual Studio 2013"-->"Visual Studio Tools"-->"VS2013 x64 本机工具命令提示" :
ppm install dmake
2.4 解压“openssl-1.1.0a.tar.gz”到当前文件夹,如得到“openssl-1.1.0a.tar”文件则再次解压“openssl-1.1.0a.tar”到当前文件夹,用以下命令切换到“openssl-1.1.0a”目录
3 Release编译
3.1 运行configure:
如果编译“openssl-1.1.0a”,执行:
cd /d E:\Projects\compile\openssl-1.1.0a
perl Configure VC-WIN64A --release --prefix=D:\comm\openssl\release_x64 --openssldir=D:\comm\ssl\release_x64
perl Configure VC-WIN64A --release --prefix=D:\comm\openssl\release_x64 --openssldir=D:\comm\ssl\release_x64 zlib --with-zlib-include=D:\comm\zlib\release_x64\include --with-zlib-lib=D:\comm\zlib\release_x64\lib\zdll.lib
perl Configure VC-WIN64A --release --prefix=D:\comm\openssl\release_x64 --openssldir=D:\comm\ssl\release_x64 zlib-dynamic --with-zlib-include=D:\comm\zlib\release_x64\include --with-zlib-lib=D:\comm\zlib\release_x64\lib\zdll.lib
注1:如果不需引入“zlib”库,则请用第1条perl命令;
注2:如果引入“zlib”静态库,则请用第2条perl命令;此方式适用于“zlib”一个工程内只有“OpenSSL”库用到或通过“OpenSSL”库用到“zlib”库的功能;这种方式编译需要修改openssl-1.1.0a\configdata.pm和openssl-1.1.0a\makefile两个文件,搜索 “/MD” 字符串,替换成 “/MT”, 这将导致静态链接 C 运行,避免了在目标机器上安装
VC 再发行包等等操作。
注3:如果引入“zlib”动态库,则请用第3条perl命令;此方式适用于所有情况;
注4:约定:本文“OpenSSL”静态库库引入“zlib”静态库,“OpenSSL”动态库引入“zlib”动态库;
3.2 编译、测试、安装、清除上次的编译以便重新编译:
nmake all
nmake install
nmake distclean
4 Debug编译
4.1 运行configure:
如果编译“openssl-1.1.0a”,执行:
cd /d E:\Projects\compile\openssl-1.1.0a
perl Configure VC-WIN64A --debug --prefix=D:\comm\openssl\debug_x64 --openssldir=D:\comm\ssl\debug_x64
perl Configure VC-WIN64A --debug --prefix=D:\comm\openssl\debug_x64 --openssldir=D:\comm\ssl\debug_x64 zlib --with-zlib-include=D:\comm\zlib\debug_x64\include --with-zlib-lib=D:\comm\zlib\debug_x64\lib\zdll.lib
perl Configure VC-WIN64A --debug --prefix=D:\comm\openssl\debug_x64 --openssldir=D:\comm\ssl\debug_x64 zlib-dynamic --with-zlib-include=D:\comm\zlib\debug_x64\include --with-zlib-lib=D:\comm\zlib\debug_x64\lib\zdll.lib
注1:如果不需引入“zlib”库,则请用第1条perl命令;
注2:如果引入“zlib”静态库,则请用第2条perl命令;此方式适用于“zlib”一个工程内只有“OpenSSL”库用到或通过“OpenSSL”库用到“zlib”库的功能;这种方式编译需要修改openssl-1.1.0a\configdata.pm和openssl-1.1.0a\makefile两个文件,搜索 “/MDd” 字符串,替换成 “/MTd”, 这将导致静态链接 C 运行,避免了在目标机器上安装
VC 再发行包等等操作。
注3:如果引入“zlib”动态库,则请用第3条perl命令;此方式适用于所有情况;
注4:约定:本文“OpenSSL”静态库库引入“zlib”静态库,“OpenSSL”动态库引入“zlib”动态库;
4.2 编译、测试、安装、清除上次的编译以便重新编译:
nmake all
nmake install
nmake distclean
5 如果不想编译,直接下载OpenSSL安装包
Binary Distributions:http://www./related/binaries.html
OpenSSL for Windows:http://www./products/Win32OpenSSL.html
6 参考文章
在 Windows下用 Visual Studio 编译 OpenSSL 1.1.0:http://www.cnblogs.com/chinalantian/p/5819105.html
|