1 openssl编译基本信息

1.1 openssl版本信息

openssl 官网:https://www.openssl.org/ 
稳定版本LTS版本:https://www.openssl.org/source/openssl-1.0.2j.tar.gz

官网上说1.0.2版本是支持到2019-12-31的长期支持版本。 
官网版本说明:https://www.openssl.org/policies/releasestrat.html

•Version 1.1.0 will be supported until 2018-08-31. 
•Version 1.0.2 will be supported until 2019-12-31 (LTS). 
•Support for version 1.0.1 will cease on 2016-12-31. No further releases of 1.0.1 will be made after that date. Security fixes only will be applied to 1.0.1 until then. 
•Version 1.0.0 is no longer supported. •Version 0.9.8 is no longer supported.

1.2 windows版本编译依赖

编译opensll windows 版本需要 perl,记得安装时设置perl的bin 目录到系统path环境变量中,是你在cmd窗口可以正常使用perl -version查看版本信息即可。 
perl下载地址 http://www.activestate.com/activeperl/downloads 
我使用的是ActivePerl-5.24.0.2400-MSWin32-x86-64int-300560.exe版本。x64为系统应该2个都可以。 
ActivePerl-5.24.0.2400-MSWin32-x86-64int-300560.exe 
ActivePerl-5.24.0.2400-MSWin32-x64-300558.exe

1.3 操作系统环境

windows 10 企业版本(10.0.14393)。vs2015 update3(14.0.25431.01)。如果编译其他vs版本,只要把vs2015换成对应visual studio版本即可。

1.4 源码下载

源码获取有3中方式: 
A:在官网下载文档版本压缩包openssl-1.0.2j.tar.gz。(https://www.openssl.org/source/openssl-1.0.2j.tar.gz) 
B:从openssl私有git仓库下载。https://www.openssl.org/source/gitrepo.html。

git clone git://git.openssl.org/openssl.git
  • 1

C:github上opensll的代码仓库。建议使用github上的代码。 
github地址:https://github.com/openssl/openssl

使用cmd命令窗口,进入d盘源码目录,进行如下操作:

cd d:\git
git clone https://github.com/openssl/openssl.git
cd d:\git\openssl
rem 迁出稳定版本1.0.2j,并建立自己本地分支b1.0.2j
git checkout OpenSSL_1_0_2j -b b1.0.2j
  • 1
  • 2
  • 3
  • 4
  • 5

2 使用vs2015 编译openssl

直接把下面的对应vs版本的bat脚本拷贝到你的cmd窗口中运行,每个vs版本需要在单独的cmd窗口运行, 
1 替换 Visual Studio 的路径为你自己的路径, 
2 替换 d:/install/openssl-1.0.2j 为你自己的输出路径, 
运行后,即可在d:/install/openssl-1.0.2j 下找到自己编译的8个版本openssl库 和 头文件。

rem 编译x86位参考INSTALL.W32说明文件
rem 如果你要编译不同的visualStudio版本,每个vs版本要单独开一个cmd窗口来操作,以免受到上一个vs版本环境变量的影响。
rem 使用vs2015 x86编译环境,运行下面这句话,就启用了vs2015的x86环境
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat"rem 一定要注意INSTALL.W32的文档说明,win32 release 版本需要指定no-asm,并且使用ms\do_nasm.bat脚本
rem 生成win32/release静态库lib
nmake -f ms\nt.mak clean
rmdir /S /Q out32
rmdir /S /Q tmp32
perl Configure VC-WIN32 no-asm --prefix=d:/install/openssl-1.0.2j/vs2015/lib/win32/release
ms\do_nasm.bat
nmake -f ms\nt.mak install
rem 运行测试程序
cd out32
..\ms\test
cd ..rem 生成win32/release动态库dll
nmake -f ms\ntdll.mak clean
rmdir /S /Q out32dll
rmdir /S /Q tmp32dll
perl Configure VC-WIN32 no-asm --prefix=d:/install/openssl-1.0.2j/vs2015/dll/win32/release
ms\do_nasm.bat
nmake -f ms\ntdll.mak install
rem 运行测试程序
cd out32dll
..\ms\test
cd ..rem 生成win32/debug静态库lib
nmake -f ms\nt.mak clean
rmdir /S /Q out32.dbg
rmdir /S /Q tmp32.dbg
perl Configure debug-VC-WIN32 no-asm --prefix=d:/install/openssl-1.0.2j/vs2015/lib/win32/debug
ms\do_ms.bat
nmake -f ms\nt.mak install
rem 运行测试程序
cd out32.dbg
..\ms\test
cd ..rem 生成win32/debug动态库dll
nmake -f ms\ntdll.mak clean
rmdir /S /Q out32dll.dbg
rmdir /S /Q tmp32dll.dbg
perl Configure debug-VC-WIN32 no-asm --prefix=d:/install/openssl-1.0.2j/vs2015/dll/win32/debug
ms\do_ms.bat
nmake -f ms\ntdll.mak install
rem 运行测试程序
cd out32dll.dbg
..\ms\test
cd ..rem 编译x64位参考INSTALL.W64说明文件
rem 如果你要编译不同的visualStudio版本,每个vs版本要单独开一个cmd窗口来操作,以免受到上一个vs版本环境变量的影响。
rem 使用vs2015 x64编译环境,如果使用其他vs版本,只需修改这个运行环境
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat"rem 生成win64/release静态库lib
nmake -f ms\nt.mak clean
rmdir /S /Q out32
rmdir /S /Q tmp32
perl Configure VC-WIN64A --prefix=d:/install/openssl-1.0.2j/vs2015/lib/win64/release
ms\do_win64a.bat
nmake -f ms\nt.mak install
rem 运行测试程序
cd out32
..\ms\test
cd ..rem 生成win64/release动态库dll
nmake -f ms\ntdll.mak clean
rmdir /S /Q out32dll
rmdir /S /Q tmp32dll
perl Configure VC-WIN64A --prefix=d:/install/openssl-1.0.2j/vs2015/dll/win64/release
ms\do_win64a.bat
nmake -f ms\ntdll.mak install
rem 运行测试程序
cd out32dll
..\ms\test
cd ..rem 生成win64/debug静态库lib
nmake -f ms\nt.mak clean
rmdir /S /Q out32.dbg
rmdir /S /Q tmp32.dbg
perl Configure debug-VC-WIN64A --prefix=d:/install/openssl-1.0.2j/vs2015/lib/win64/debug
ms\do_win64a.bat
nmake -f ms\nt.mak install
rem 运行测试程序
cd out32.dbg
..\ms\test
cd ..rem 生成win64/debug动态库dll
nmake -f ms\ntdll.mak clean
rmdir /S /Q out32dll.dbg
rmdir /S /Q tmp32dll.dbg
perl Configure debug-VC-WIN64A --prefix=d:/install/openssl-1.0.2j/vs2015/dll/win64/debug
ms\do_win64a.bat
nmake -f ms\ntdll.mak install
rem 运行测试程序
cd out32dll.dbg
..\ms\test
cd ..rem vs2015 生成的4个版本90MB+
rem 通常我们只需要生成的win32/release win64/release版本。
rem 其他版本只是调试使用
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110

3 使用vs2013 编译openssl

rem 编译x86位参考INSTALL.W32说明文件
rem 如果你要编译不同的visualStudio版本,每个vs版本要单独开一个cmd窗口来操作,以免受到上一个vs版本环境变量的影响。
rem 使用vs2013 x86编译环境 vs2013 update5 (12.0.40629.00)
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"rem 一定要注意INSTALL.W32的文档说明,win32 release 版本需要指定no-asm,并且使用ms\do_nasm.bat脚本
rem 生成win32/release静态库lib
nmake -f ms\nt.mak clean
rmdir /S /Q out32
rmdir /S /Q tmp32
perl Configure VC-WIN32 no-asm --prefix=d:/install/openssl-1.0.2j/vs2013/lib/win32/release
ms\do_nasm.bat
nmake -f ms\nt.mak install
rem 运行测试程序
cd out32
..\ms\test
cd ..rem 生成win32/release动态库dll
nmake -f ms\ntdll.mak clean
rmdir /S /Q out32dll
rmdir /S /Q tmp32dll
perl Configure VC-WIN32 no-asm --prefix=d:/install/openssl-1.0.2j/vs2013/dll/win32/release
ms\do_nasm.bat
nmake -f ms\ntdll.mak install
rem 运行测试程序
cd out32dll
..\ms\test
cd ..rem 生成win32/debug静态库lib
nmake -f ms\nt.mak clean
rmdir /S /Q out32.dbg
rmdir /S /Q tmp32.dbg
perl Configure debug-VC-WIN32 no-asm --prefix=d:/install/openssl-1.0.2j/vs2013/lib/win32/debug
ms\do_ms.bat
nmake -f ms\nt.mak install
rem 运行测试程序
cd out32.dbg
..\ms\test
cd ..rem 生成win32/debug动态库dll
nmake -f ms\ntdll.mak clean
rmdir /S /Q out32dll.dbg
rmdir /S /Q tmp32dll.dbg
perl Configure debug-VC-WIN32 no-asm --prefix=d:/install/openssl-1.0.2j/vs2013/dll/win32/debug
ms\do_ms.bat
nmake -f ms\ntdll.mak install
rem 运行测试程序
cd out32dll.dbg
..\ms\test
cd ..rem 编译x64位参考INSTALL.W64说明文件
rem 使用vs2013 x64编译环境,如果使用其他vs版本,只需修改这个运行环境
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\vcvars64.bat"rem 生成win64/release静态库lib
nmake -f ms\nt.mak clean
rmdir /S /Q out32
rmdir /S /Q tmp32
perl Configure VC-WIN64A --prefix=d:/install/openssl-1.0.2j/vs2013/lib/win64/release
ms\do_win64a.bat
nmake -f ms\nt.mak install
rem 运行测试程序
cd out32
..\ms\test
cd ..rem 生成win64/release动态库dll
nmake -f ms\ntdll.mak clean
rmdir /S /Q out32dll
rmdir /S /Q tmp32dll
perl Configure VC-WIN64A --prefix=d:/install/openssl-1.0.2j/vs2013/dll/win64/release
ms\do_win64a.bat
nmake -f ms\ntdll.mak install
rem 运行测试程序
cd out32dll
..\ms\test
cd ..rem 生成win64/debug静态库lib
nmake -f ms\nt.mak clean
rmdir /S /Q out32.dbg
rmdir /S /Q tmp32.dbg
perl Configure debug-VC-WIN64A --prefix=d:/install/openssl-1.0.2j/vs2013/lib/win64/debug
ms\do_win64a.bat
nmake -f ms\nt.mak install
rem 运行测试程序
cd out32.dbg
..\ms\test
cd ..rem 生成win64/debug动态库dll
nmake -f ms\ntdll.mak clean
rmdir /S /Q out32dll.dbg
rmdir /S /Q tmp32dll.dbg
perl Configure debug-VC-WIN64A --prefix=d:/install/openssl-1.0.2j/vs2013/dll/win64/debug
ms\do_win64a.bat
nmake -f ms\ntdll.mak install
rem 运行测试程序
cd out32dll.dbg
..\ms\test
cd ..rem vs2013 生成的8个版本105MB
rem 通常我们只需要生成的win32/release win64/release版本。
rem 其他版本只是调试使用
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109

4 使用vs2012 编译openssl

rem 编译x86位参考INSTALL.W32说明文件
rem 如果你要编译不同的visualStudio版本,每个vs版本要单独开一个cmd窗口来操作,以免受到上一个vs版本环境变量的影响。
rem 使用vs2012 x86编译环境 vs2012 update5 (11.0.61219.00)
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\vcvars32.bat"rem 一定要注意INSTALL.W32的文档说明,win32 release 版本需要指定no-asm,并且使用ms\do_nasm.bat脚本
rem 生成win32/release静态库lib
nmake -f ms\nt.mak clean
rmdir /S /Q out32
rmdir /S /Q tmp32
perl Configure VC-WIN32 no-asm --prefix=d:/install/openssl-1.0.2j/vs2012/lib/win32/release
ms\do_nasm.bat
nmake -f ms\nt.mak install
rem 运行测试程序
cd out32
..\ms\test
cd ..rem 生成win32/release动态库dll
nmake -f ms\ntdll.mak clean
rmdir /S /Q out32dll
rmdir /S /Q tmp32dll
perl Configure VC-WIN32 no-asm --prefix=d:/install/openssl-1.0.2j/vs2012/dll/win32/release
ms\do_nasm.bat
nmake -f ms\ntdll.mak install
rem 运行测试程序
cd out32dll
..\ms\test
cd ..rem 生成win32/debug静态库lib
nmake -f ms\nt.mak clean
rmdir /S /Q out32.dbg
rmdir /S /Q tmp32.dbg
perl Configure debug-VC-WIN32 no-asm --prefix=d:/install/openssl-1.0.2j/vs2012/lib/win32/debug
ms\do_ms.bat
nmake -f ms\nt.mak install
rem 运行测试程序
cd out32.dbg
..\ms\test
cd ..rem 生成win32/debug动态库dll
nmake -f ms\ntdll.mak clean
rmdir /S /Q out32dll.dbg
rmdir /S /Q tmp32dll.dbg
perl Configure debug-VC-WIN32 no-asm --prefix=d:/install/openssl-1.0.2j/vs2012/dll/win32/debug
ms\do_ms.bat
nmake -f ms\ntdll.mak install
rem 运行测试程序
cd out32dll.dbg
..\ms\test
cd ..rem 编译x64位参考INSTALL.W64说明文件
rem 如果你要编译不同的visualStudio版本,每个vs版本要单独开一个cmd窗口来操作,以免受到上一个vs版本环境变量的影响。
rem 使用vs2012 x64编译环境,如果使用其他vs版本,只需修改这个运行环境
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\amd64\vcvars64.bat"rem 生成win64/release静态库lib
nmake -f ms\nt.mak clean
rmdir /S /Q out32
rmdir /S /Q tmp32
perl Configure VC-WIN64A --prefix=d:/install/openssl-1.0.2j/vs2012/lib/win64/release
ms\do_win64a.bat
nmake -f ms\nt.mak install
rem 运行测试程序
cd out32
..\ms\test
cd ..rem 生成win64/release动态库dll
nmake -f ms\ntdll.mak clean
rmdir /S /Q out32dll
rmdir /S /Q tmp32dll
perl Configure VC-WIN64A --prefix=d:/install/openssl-1.0.2j/vs2012/dll/win64/release
ms\do_win64a.bat
nmake -f ms\ntdll.mak install
rem 运行测试程序
cd out32dll
..\ms\test
cd ..rem 生成win64/debug静态库lib
nmake -f ms\nt.mak clean
rmdir /S /Q out32.dbg
rmdir /S /Q tmp32.dbg
perl Configure debug-VC-WIN64A --prefix=d:/install/openssl-1.0.2j/vs2012/lib/win64/debug
ms\do_win64a.bat
nmake -f ms\nt.mak install
rem 运行测试程序
cd out32.dbg
..\ms\test
cd ..rem 生成win64/debug动态库dll
nmake -f ms\ntdll.mak clean
rmdir /S /Q out32dll.dbg
rmdir /S /Q tmp32dll.dbg
perl Configure debug-VC-WIN64A --prefix=d:/install/openssl-1.0.2j/vs2012/dll/win64/debug
ms\do_win64a.bat
nmake -f ms\ntdll.mak install
rem 运行测试程序
cd out32dll.dbg
..\ms\test
cd ..rem vs2012 生成的8个版本105MB
rem 通常我们只需要生成的win32/release win64/release版本。
rem 其他版本只是调试使用
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110

5 使用vs2010 编译openssl

rem 编译x86位参考INSTALL.W32说明文件
rem 如果你要编译不同的visualStudio版本,每个vs版本要单独开一个cmd窗口来操作,以免受到上一个vs版本环境变量的影响。
rem 使用vs2010 x86编译环境 vs2010 SP1Rel (10.0.40219.00)
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"rem 一定要注意INSTALL.W32的文档说明,win32 release 版本需要指定no-asm,并且使用ms\do_nasm.bat脚本
rem 生成win32/release静态库lib
nmake -f ms\nt.mak clean
rmdir /S /Q out32
rmdir /S /Q tmp32
perl Configure VC-WIN32 no-asm --prefix=d:/install/openssl-1.0.2j/vs2010/lib/win32/release
ms\do_nasm.bat
nmake -f ms\nt.mak install
rem 运行测试程序
cd out32
..\ms\test
cd ..rem 生成win32/release动态库dll
nmake -f ms\ntdll.mak clean
rmdir /S /Q out32dll
rmdir /S /Q tmp32dll
perl Configure VC-WIN32 no-asm --prefix=d:/install/openssl-1.0.2j/vs2010/dll/win32/release
ms\do_nasm.bat
nmake -f ms\ntdll.mak install
rem 运行测试程序
cd out32dll
..\ms\test
cd ..rem 生成win32/debug静态库lib
nmake -f ms\nt.mak clean
rmdir /S /Q out32.dbg
rmdir /S /Q tmp32.dbg
perl Configure debug-VC-WIN32 no-asm --prefix=d:/install/openssl-1.0.2j/vs2010/lib/win32/debug
ms\do_ms.bat
nmake -f ms\nt.mak install
rem 运行测试程序
cd out32.dbg
..\ms\test
cd ..rem 生成win32/debug动态库dll
nmake -f ms\ntdll.mak clean
rmdir /S /Q out32dll.dbg
rmdir /S /Q tmp32dll.dbg
perl Configure debug-VC-WIN32 no-asm --prefix=d:/install/openssl-1.0.2j/vs2010/dll/win32/debug
ms\do_ms.bat
nmake -f ms\ntdll.mak install
rem 运行测试程序
cd out32dll.dbg
..\ms\test
cd ..rem 编译x64位参考INSTALL.W64说明文件
rem 如果你要编译不同的visualStudio版本,每个vs版本要单独开一个cmd窗口来操作,以免受到上一个vs版本环境变量的影响。
rem 使用vs2010 x64编译环境,如果使用其他vs版本,只需修改这个运行环境
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat"rem 生成win64/release静态库lib
nmake -f ms\nt.mak clean
rmdir /S /Q out32
rmdir /S /Q tmp32
perl Configure VC-WIN64A --prefix=d:/install/openssl-1.0.2j/vs2010/lib/win64/release
ms\do_win64a.bat
nmake -f ms\nt.mak install
rem 运行测试程序
cd out32
..\ms\test
cd ..rem 生成win64/release动态库dll
nmake -f ms\ntdll.mak clean
rmdir /S /Q out32dll
rmdir /S /Q tmp32dll
perl Configure VC-WIN64A --prefix=d:/install/openssl-1.0.2j/vs2010/dll/win64/release
ms\do_win64a.bat
nmake -f ms\ntdll.mak install
rem 运行测试程序
cd out32dll
..\ms\test
cd ..rem 生成win64/debug静态库lib
nmake -f ms\nt.mak clean
rmdir /S /Q out32.dbg
rmdir /S /Q tmp32.dbg
perl Configure debug-VC-WIN64A --prefix=d:/install/openssl-1.0.2j/vs2010/lib/win64/debug
ms\do_win64a.bat
nmake -f ms\nt.mak install
rem 运行测试程序
cd out32.dbg
..\ms\test
cd ..rem 生成win64/debug动态库dll
nmake -f ms\ntdll.mak clean
rmdir /S /Q out32dll.dbg
rmdir /S /Q tmp32dll.dbg
perl Configure debug-VC-WIN64A --prefix=d:/install/openssl-1.0.2j/vs2010/dll/win64/debug
ms\do_win64a.bat
nmake -f ms\ntdll.mak install
rem 运行测试程序
cd out32dll.dbg
..\ms\test
cd ..rem vs2010 生成的8个版本101MB
rem 通常我们只需要生成的win32/release win64/release版本。
rem 其他版本只是调试使用
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110

6 使用vs2008 编译openssl

rem 编译x86位参考INSTALL.W32说明文件
rem 如果你要编译不同的visualStudio版本,每个vs版本要单独开一个cmd窗口来操作,以免受到上一个vs版本环境变量的影响。
rem 使用vs2008 x86编译环境 vs2008 SP (9.0.30729.1)
"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"rem 一定要注意INSTALL.W32的文档说明,win32 release 版本需要指定no-asm,并且使用ms\do_nasm.bat脚本
rem 生成win32/release静态库lib
nmake -f ms\nt.mak clean
rmdir /S /Q out32
rmdir /S /Q tmp32
perl Configure VC-WIN32 no-asm --prefix=d:/install/openssl-1.0.2j/vs2008/lib/win32/release
ms\do_nasm.bat
nmake -f ms\nt.mak install
rem 运行测试程序
cd out32
..\ms\test
cd ..rem 生成win32/release动态库dll
nmake -f ms\ntdll.mak clean
rmdir /S /Q out32dll
rmdir /S /Q tmp32dll
perl Configure VC-WIN32 no-asm --prefix=d:/install/openssl-1.0.2j/vs2008/dll/win32/release
ms\do_nasm.bat
nmake -f ms\ntdll.mak install
rem 运行测试程序
cd out32dll
..\ms\test
cd ..rem 生成win32/debug静态库lib
nmake -f ms\nt.mak clean
rmdir /S /Q out32.dbg
rmdir /S /Q tmp32.dbg
perl Configure debug-VC-WIN32 no-asm --prefix=d:/install/openssl-1.0.2j/vs2008/lib/win32/debug
ms\do_ms.bat
nmake -f ms\nt.mak install
rem 运行测试程序
cd out32.dbg
..\ms\test
cd ..rem 生成win32/debug动态库dll
nmake -f ms\ntdll.mak clean
rmdir /S /Q out32dll.dbg
rmdir /S /Q tmp32dll.dbg
perl Configure debug-VC-WIN32 no-asm --prefix=d:/install/openssl-1.0.2j/vs2008/dll/win32/debug
ms\do_ms.bat
nmake -f ms\ntdll.mak install
rem 运行测试程序
cd out32dll.dbg
..\ms\test
cd ..rem 编译x64位参考INSTALL.W64说明文件
rem 如果你要编译不同的visualStudio版本,每个vs版本要单独开一个cmd窗口来操作,以免受到上一个vs版本环境变量的影响。
rem 使用vs2008 x64编译环境,如果使用其他vs版本,只需修改这个运行环境
"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\vcvarsamd64.bat"rem 生成win64/release静态库lib
nmake -f ms\nt.mak clean
rmdir /S /Q out32
rmdir /S /Q tmp32
perl Configure VC-WIN64A --prefix=d:/install/openssl-1.0.2j/vs2008/lib/win64/release
ms\do_win64a.bat
nmake -f ms\nt.mak install
rem 运行测试程序
cd out32
..\ms\test
cd ..rem 生成win64/release动态库dll
nmake -f ms\ntdll.mak clean
rmdir /S /Q out32dll
rmdir /S /Q tmp32dll
perl Configure VC-WIN64A --prefix=d:/install/openssl-1.0.2j/vs2008/dll/win64/release
ms\do_win64a.bat
nmake -f ms\ntdll.mak install
rem 运行测试程序
cd out32dll
..\ms\test
cd ..rem 生成win64/debug静态库lib
nmake -f ms\nt.mak clean
rmdir /S /Q out32.dbg
rmdir /S /Q tmp32.dbg
perl Configure debug-VC-WIN64A --prefix=d:/install/openssl-1.0.2j/vs2008/lib/win64/debug
ms\do_win64a.bat
nmake -f ms\nt.mak install
rem 运行测试程序
cd out32.dbg
..\ms\test
cd ..rem 生成win64/debug动态库dll
nmake -f ms\ntdll.mak clean
rmdir /S /Q out32dll.dbg
rmdir /S /Q tmp32dll.dbg
perl Configure debug-VC-WIN64A --prefix=d:/install/openssl-1.0.2j/vs2008/dll/win64/debug
ms\do_win64a.bat
nmake -f ms\ntdll.mak install
rem 运行测试程序
cd out32dll.dbg
..\ms\test
cd ..rem vs2008 生成的8个版本99.5MB
rem 通常我们只需要生成的win32/release win64/release版本。
rem 其他版本只是调试使用
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110

7 使用vs2005 编译openssl

rem 编译x86位参考INSTALL.W32说明文件
rem 如果你要编译不同的visualStudio版本,每个vs版本要单独开一个cmd窗口来操作,以免受到上一个vs版本环境变量的影响。
rem 使用vs2005 x86编译环境 vs2005 (8.0.50727.4039)
"C:\Program Files (x86)\Microsoft Visual Studio 8\VC\bin\vcvars32.bat"rem 一定要注意INSTALL.W32的文档说明,win32 release 版本需要指定no-asm,并且使用ms\do_nasm.bat脚本
rem 生成win32/release静态库lib
nmake -f ms\nt.mak clean
rmdir /S /Q out32
rmdir /S /Q tmp32
perl Configure VC-WIN32 no-asm --prefix=d:/install/openssl-1.0.2j/vs2005/lib/win32/release
ms\do_nasm.bat
nmake -f ms\nt.mak install
rem 运行测试程序
cd out32
..\ms\test
cd ..rem 生成win32/release动态库dll
nmake -f ms\ntdll.mak clean
rmdir /S /Q out32dll
rmdir /S /Q tmp32dll
perl Configure VC-WIN32 no-asm --prefix=d:/install/openssl-1.0.2j/vs2005/dll/win32/release
ms\do_nasm.bat
nmake -f ms\ntdll.mak install
rem 运行测试程序
cd out32dll
..\ms\test
cd ..rem 生成win32/debug静态库lib
nmake -f ms\nt.mak clean
rmdir /S /Q out32.dbg
rmdir /S /Q tmp32.dbg
perl Configure debug-VC-WIN32 no-asm --prefix=d:/install/openssl-1.0.2j/vs2005/lib/win32/debug
ms\do_ms.bat
nmake -f ms\nt.mak install
rem 运行测试程序
cd out32.dbg
..\ms\test
cd ..rem 生成win32/debug动态库dll
nmake -f ms\ntdll.mak clean
rmdir /S /Q out32dll.dbg
rmdir /S /Q tmp32dll.dbg
perl Configure debug-VC-WIN32 no-asm --prefix=d:/install/openssl-1.0.2j/vs2005/dll/win32/debug
ms\do_ms.bat
nmake -f ms\ntdll.mak install
rem 运行测试程序
cd out32dll.dbg
..\ms\test
cd ..rem 编译x64位参考INSTALL.W64说明文件
rem 如果你要编译不同的visualStudio版本,每个vs版本要单独开一个cmd窗口来操作,以免受到上一个vs版本环境变量的影响。
rem 使用vs2005 x64编译环境,如果使用其他vs版本,只需修改这个运行环境
"C:\Program Files (x86)\Microsoft Visual Studio 8\VC\bin\amd64\vcvarsamd64.bat"rem 生成win64/release静态库lib
nmake -f ms\nt.mak clean
rmdir /S /Q out32
rmdir /S /Q tmp32
perl Configure VC-WIN64A --prefix=d:/install/openssl-1.0.2j/vs2005/lib/win64/release
ms\do_win64a.bat
nmake -f ms\nt.mak install
rem 运行测试程序
cd out32
..\ms\test
cd ..rem 生成win64/release动态库dll
nmake -f ms\ntdll.mak clean
rmdir /S /Q out32dll
rmdir /S /Q tmp32dll
perl Configure VC-WIN64A --prefix=d:/install/openssl-1.0.2j/vs2005/dll/win64/release
ms\do_win64a.bat
nmake -f ms\ntdll.mak install
rem 运行测试程序
cd out32dll
..\ms\test
cd ..rem 生成win64/debug静态库lib
nmake -f ms\nt.mak clean
rmdir /S /Q out32.dbg
rmdir /S /Q tmp32.dbg
perl Configure debug-VC-WIN64A --prefix=d:/install/openssl-1.0.2j/vs2005/lib/win64/debug
ms\do_win64a.bat
nmake -f ms\nt.mak install
rem 运行测试程序
cd out32.dbg
..\ms\test
cd ..rem 生成win64/debug动态库dll
nmake -f ms\ntdll.mak clean
rmdir /S /Q out32dll.dbg
rmdir /S /Q tmp32dll.dbg
perl Configure debug-VC-WIN64A --prefix=d:/install/openssl-1.0.2j/vs2005/dll/win64/debug
ms\do_win64a.bat
nmake -f ms\ntdll.mak install
rem 运行测试程序
cd out32dll.dbg
..\ms\test
cd ..rem vs2005 生成的8个版本96.9MB
rem 通常我们只需要生成的win32/release win64/release版本。
rem 其他版本只是调试使用
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110

8 使用自己编译的OpenSSL库文件。

这里测试一个使用vs2015编译的32位动态库的D:\install\openssl-1.0.2j\vs2015\dll\win32\release版本。不管自己的工程是debug还是release版本,都引入openssl的release版本动态库。因为实际上我们自己的工程基本不会修改openssl代码。如果是自己研究,需要调试跟踪openssl的代码,需要引入openssl对应的debug版本。 
新建一个vs2015空的32位控制台工程,并引入OpenSSL库文件。

8.1 新建一个vs2015空的32位控制台工程,工程上面右键菜单选择属性,配置属性C/C++附加包含目录,添加内容:D:\install\openssl-1.0.2j\vs2015\dll\win32\release\include 
注意:实际工程中,需要把vs2015目录内容拷贝到自己工程的特定第三方目录,然后使用相对路径引入。 

8.2 配置属性==>连接器==>常规==>附加库目录,添加D:\install\openssl-1.0.2j\vs2015\dll\win32\release\lib; 

8.3 配置属性==>连接器==>输入==>附近依赖项,添加 libeay32.lib;ssleay32.lib; 

8.4 添加一个测试的c++文件。这里在其他人的blog上面引入了一个测试文件。OpenSSLTest.cpp。来自http://blog.csdn.net/gpltoken/article/details/53011068。

// 该代码来自 http://blog.csdn.net/gpltoken/article/details/53011068
// 把文件目录做了修改,解密后的文件多了一个换行符
//
#include <openssl/evp.h>
#include <stdio.h>#pragma warning(disable:4996)#define N 1024
#define IN
//Aes算法ecb模式加密文件
/**********************************************************************
函数名称:AesEncryptFile
函数功能:加密文件
处理过程:
1.根据选择的密码算法以及口令,生成key和iv。
2.把文件头写入密文文件
3.循环读取原文文件数据加密后保存到密文文件路径中。
参数说明:
szSrc:[IN] char *,待加密的原文文件路径
szTarget:[IN] char *,加密后的密文文件保存路径
key:[IN] unsigned char *, 口令
iType:[IN] int, 加密类型(128或256)
返回值:成功返回1,否则返回0
************************************************************************/
int AesEncryptFile(IN char * szSrc,IN char * szTarget,IN unsigned char * key,IN int iType)
{unsigned char ukey[EVP_MAX_KEY_LENGTH];unsigned char iv[EVP_MAX_IV_LENGTH];unsigned char in[N];int inl;   //输入数据大小unsigned char out[N];int outl;   //输出数据大小int isSuccess;FILE *fpIn;FILE *fpOut;EVP_CIPHER_CTX ctx;   //evp加密上下文环境const   EVP_CIPHER *cipher;fpIn = fopen(szSrc, "rb");if (fpIn == NULL){printf("fopen szSrc failed");return 0;}fpOut = fopen(szTarget, "w+");if (fpOut == NULL){printf("fopen szTarget failed");fclose(fpIn);return 0;}//选择算法if (iType == 128){cipher = EVP_aes_128_ecb();}else if (iType == 256){cipher = EVP_aes_256_ecb();}else{printf("iType should be 128 or 256.");fclose(fpIn);fclose(fpOut);return 0;}//生成ukey和ivint len = sizeof(key);EVP_BytesToKey(cipher, EVP_md5(), NULL, (const unsigned char *)key, len - 1, 1, ukey, iv);//初始化ctx,加密算法初始化EVP_CIPHER_CTX_init(&ctx);isSuccess = EVP_EncryptInit_ex(&ctx, cipher, NULL, ukey, iv);if (!isSuccess){printf("EVP_EncryptInit_ex() failed");EVP_CIPHER_CTX_cleanup(&ctx);fclose(fpIn);fclose(fpOut);return 0;}//加密文件for (;;){inl = fread(in, 1, N, fpIn);if (inl <= 0)break;isSuccess = EVP_EncryptUpdate(&ctx, out, &outl, in, inl);if (!isSuccess){printf("EVP_EncryptInit_ex() failed");EVP_CIPHER_CTX_cleanup(&ctx);fclose(fpIn);fclose(fpOut);return 0;}fwrite(out, 1, outl, fpOut);}isSuccess = EVP_EncryptFinal_ex(&ctx, out, &outl);if (!isSuccess){printf("EVP_EncryptInit_ex() failed");EVP_CIPHER_CTX_cleanup(&ctx);fclose(fpIn);fclose(fpOut);return 0;}fwrite(out, 1, outl, fpOut);printf("加密成功\n");EVP_CIPHER_CTX_cleanup(&ctx);fclose(fpIn);fclose(fpOut);return 1;
}//Aes算法ecb模式解密文件
/**********************************************************************
函数名称:AesDecryptFile
函数功能:解密文件
处理过程:
1.根据选择的密码算法以及口令,生成key和iv。
2.把文件头写入密文文件
3.循环读取原文文件数据加密后保存到密文文件路径中。
参数说明:
szSrc:[IN] char *,待解密的密文文件路径
szTarget:[IN] char *,解密后的解密文件保存路径
key:[IN] unsigned char *, 口令
iType:[IN] int, 加密类型(128或256)
返回值:成功返回1,否则返回0
************************************************************************/
int AesDecryptFile(IN char * szSrc,IN char * szTarget,IN unsigned char * key,IN int iType)
{unsigned char ukey[EVP_MAX_KEY_LENGTH];unsigned char iv[EVP_MAX_IV_LENGTH];unsigned char in[N];int inl;   //输入数据大小unsigned char out[N];int outl;   //输出数据大小int isSuccess;FILE *fpIn;FILE *fpOut;EVP_CIPHER_CTX ctx;   //evp加密上下文环境const EVP_CIPHER *cipher;fpIn = fopen(szSrc, "rb");if (fpIn == NULL){printf("fopen szSrc failed");return 0;}fpOut = fopen(szTarget, "w+");if (fpOut == NULL){printf("fopen szTarget failed");fclose(fpIn);return 0;}//选择算法if (iType == 128){cipher = EVP_aes_128_ecb();}else if (iType == 256){cipher = EVP_aes_256_ecb();}else{printf("iType should be 128 or 256.");fclose(fpIn);fclose(fpOut);return 0;}//生成ukey和ivint len = sizeof(key);EVP_BytesToKey(cipher, EVP_md5(), NULL, (const unsigned char *)key, len - 1, 1, ukey, iv);//初始化ctx,加密算法初始化EVP_CIPHER_CTX_init(&ctx);isSuccess = EVP_DecryptInit_ex(&ctx, cipher, NULL, ukey, iv);if (!isSuccess){printf("EVP_DecryptInit_ex() failed");EVP_CIPHER_CTX_cleanup(&ctx);fclose(fpIn);fclose(fpOut);return 0;}//加密文件for (;;){inl = fread(in, 1, N, fpIn);if (inl <= 0)break;isSuccess = EVP_DecryptUpdate(&ctx, out, &outl, in, inl);if (!isSuccess){printf("EVP_EncryptInit_ex() failed");EVP_CIPHER_CTX_cleanup(&ctx);fclose(fpIn);fclose(fpOut);return 0;}fwrite(out, 1, outl, fpOut);}isSuccess = EVP_DecryptFinal_ex(&ctx, out, &outl);if (!isSuccess){printf("EVP_DecryptInit_ex() failed");EVP_CIPHER_CTX_cleanup(&ctx);fclose(fpIn);fclose(fpOut);return 0;}fwrite(out, 1, outl, fpOut);printf("解密成功\n");EVP_CIPHER_CTX_cleanup(&ctx);fclose(fpIn);fclose(fpOut);return 1;
}int main()
{
#if _DEBUGchar *Src = "../debug/test.txt";char *TargetEnc = "../debug/test.txt.enc";char *TargetDec = "../debug/test.txt.dec";
#else 如果调试也需要指定正确的目录//char *Src = "../Release/test.txt";//char *TargetEnc = "../Release/test.txt.enc";//char *TargetDec = "../Release/test.txt.dec";char *Src = "test.txt";char *TargetEnc = "test.txt.enc";char *TargetDec = "test.txt.dec";
#endifunsigned char key[32] = "abcdefg";int rv = AesEncryptFile(Src, TargetEnc, key, 128);if (rv != 1){printf("AesEncryptFile() failed");return 1;}rv = AesDecryptFile(TargetEnc, TargetDec, key, 128);if (rv != 1){printf("AesDecryptFile() failed");return 1;}return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274

8.5 Build 项目,生成debug/OpenSSLTest.exe文件 

8.6 把D:\install\openssl-1.0.2j\vs2015\dll\win32\release\bin目录下的libeay32.dll和ssleay32.dll拷贝到与 debug/OpenSSLTest.exe 相同的目录下。在debug/OpenSSLTest.exe 目录下,生成一个文本文件,text.txt,随便写些内容后,F5,运行调试OpenSSLTest.exe,生成test.txt的加密文件test.txt.enc和test.txt.enc的解密文件test.txt.dec。

09 关于运行时库的选中

openssl基本都会作为第三方库引入工程。而且往往会作为次级库引入,第三方库在编译使用的运行时库一般会是动态运行时,也有选择静态运行时库的。openssl的编译也面临同样问题。默认使用动态运行时库。通过修改配置项,可以选择静态运行时库。

09.01 运行时库默认选项

nmake -f ms/ntdll.mak
  • 1

该命令生成动态库,默认使用的是MD

nmake -f ms/nt.mak
  • 1

该命令生成静态库,默认使用的是MT

09.02 更改运行时库方法

想生成使用静态链接运行时库的动态库则采用下面方法 
复制一个ntdll.mak并命名为ntdll_mt.mak,修改里面的 “CFLAG= /MD /Ox …………..” 为/MT ,然后重新编译,执行 nmake -f ms/ntdll_mt.mak 
想生成使用动态链接运行时库的静态库则采用下面方法

复制一个nt.mak并命名为nt_md.mak,修改里面的 “CFLAG= /MT /Ox …………..” 为/MD ,然后重新编译 ,执行 nmake -f ms/nt_md.mak

https://blog.csdn.net/longji/article/details/53573173

vs2015 openssl-1.0.2j编译相关推荐

  1. OpenSSL(openssl-1.0.1h)编译与安装(Win7)

    参考: http://blog.chinaunix.net/uid-20479991-id-216269.html 1. 准备: 1.1 安装perl环境, 下载地址: http://dlsw.bai ...

  2. openssh 7.4 java使用_openssh/openssl升级到7.4和1.0.2j 源码方式

    tar -xvf openssh-7.4p1.tar.gz tar -xvf openssl-1.0.2j.tar.gz 升级 openssl 到1.0.2j cd openssl-1.0.2j ./ ...

  3. openssl / vs2019 编译 openssl 1.0.2u 过程说明

    一.准备 1.安装 perl http://strawberryperl.com/download/5.28.1.1/strawberry-perl-5.28.1.1-64bit.msi 2.下载 o ...

  4. VC2008下使用OpenSSL 1.0.0g(免编译)

    摘要: 运行时库附加依赖项多线程(/MT)libeay32MT.lib ssleay32MT.lib多线程调试(/MTd)libeay32MTd.lib ssleay32... id="cp ...

  5. openssl 1.0.2k-fips 升级到 openssl-3.0.5

    近日国家信息安全漏洞库公布了关于OpenSSL 操作系统命令注入漏洞(CVE-2022-1292),特此将目前使用的openssl 1.0.2k-fips 升级到 openssl-3.0.5 1.下载 ...

  6. openssl 1.0.2k-fips 升级到 openssl-3.0.3

    近期公司内部安全扫描发现OpenSSL存在漏洞,需要升级. 下载地址: Openssl官网:https://www.openssl.org/source/下载3.0.3地址: https://www. ...

  7. Win10 64位+VS2015+Opencv3.3.0安装配置

    引言 最近准备搞一搞机器视觉方面的研究,所以着手进行环境的搭建.所使用的环境是Win10 64位+VS2015+Opencv3.3.0安装配置 Win10 64位+VS2015+Opencv3.3.0 ...

  8. 编译内核启用KASan动态检测内核内存错误功能(ubuntu16.04 4.4.0内核编译升级到linux-4.4.252版本)

    目录 一.编译内核并配置支持KAsan 1.下载源码 2.安装编译内核必须的库 3.清理之前内核编译生成及相关配置 4.配置内核参数 5.开始编译 6.模块(驱动)安装 7.安装新编译的内核 8.修改 ...

  9. 极客日报:华为发布矿山鸿蒙操作系统“矿鸿”;​韩国对谷歌罚款11亿元;OpenSSL 3.0 发布

    一分钟速览新闻点! 华为发布矿山鸿蒙操作系统"矿鸿" 抖音回应"涉嫌盗取腾讯关系链":系谣言,法院已立案 腾讯注册QQ元宇宙商标 中国云服务市场已达66亿美元: ...

最新文章

  1. 阿里云亮相2019联通合作伙伴大会,边缘计算等3款云产品助力5G时代产业数字化转型...
  2. Redis (一)Redis简介、安装部署
  3. 用Tableau画改进版幂函数柱状图
  4. Java中String字符串toString()、String.valueOf()、String强转、+ 的区别
  5. 显示Intent和隐式Intent
  6. PLSQL_性能优化系列10_Oracle Array数据组优化
  7. selenium通过autoit实现上传和下载
  8. Gitter - 高颜值GitHub小程序客户端诞生记 1
  9. Linux批量部署无密钥脚本
  10. xtreme toolkit pro——CXTPReportControl控件教程
  11. 图书馆座位预约系统管理/基于微信小程序的图书馆座位预约系统
  12. B. The Monster and the Squirrel
  13. Elastic 许可更新
  14. shell命令执行完的退出状态详解+if语句的定义方法
  15. Win10使用自带工具屏幕录制
  16. Spring MVC工作流程图
  17. 帮我写一份演化博弈的MATLAB代码
  18. 小米台灯突然自己亮了_米家又上三款新品,台灯耳机都有升级
  19. 软件工程——软件编码
  20. linux下flash大小如何查看器,Flash 型号和block大小查看

热门文章

  1. 【征稿】第三届电子、信息与计算技术前沿国际会议(ICFEICT 2023)
  2. ESP8266-Arduino编程实例-LIS3MDL磁场传感器驱动
  3. linux hwclock -r显示的HWC TIME(硬件时钟时间)与timedatectl结果中的RTC TIME(实时时钟时间)有什么区别?BIOS时钟源
  4. taobao.itemprops.get( 获取标准商品类目属性 )
  5. 为什么不是每个人都过着他梦想中的生活呢?
  6. 浅谈Coreseek、Sphinx-for-chinaese、Sphinx+Scws的区别
  7. docker exec -it进入及退出容器
  8. 《斯坦福高效睡眠法》读书笔记思维导图版,成年人的睡眠解决法
  9. 常用的3种高效睡眠法,因人而异
  10. 【逆向工程】在PE结构空白区段插入代码