Windows 编译 openssl

前言: 虽然很多人都有发过一样的文章,但是遇到的问题并不都一样。

1.必备:


1.源码 (GitHub)
2.NASM  
https://www.nasm.us/pub/nasm/releasebuilds/2.14.03rc2/win32/nasm-2.14.03rc2-installer-x86.exe
3.Perl
http://forspeed.onlinedown.net/down/ActivePerl-5.20.2MSWin32.zip
4.VS2019 + Windows 10 SDK 
https://download.microsoft.com/download/4/2/2/42245968-6A79-4DA7-A5FB-08C0AD0AE661/windowssdk/winsdksetup.exe

2.设置环境变量


Perl 和 NASM 的路径: 
set path=%path%;C:\Perl\bin

set path=%path%;C:\Program Files (x86)\NASM

3.编译32位, 64位的 Windows sdk 缺少 gdi32.lib 文件,坑逼。

启动 32位版本的 developer command prompt。注:必须是32位的, nmake 和 cl 程序都必须确保是32位的。

perl Configure  no-shared VC-WIN32 --prefix=D:\Programming\ThirdParty\openSSL 

nmake test 

Windows 编译 openssl_第1张图片

4.安装

管理员权限启动 developer command prompt 

nmake install 

 

附录:(各环境变量的值)

C:\Users\myuser\Downloads\openssl-OpenSSL_1_1_1d\openssl-OpenSSL_1_1_1d>echo %include%
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\ATLMFC\include;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include;C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared;C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt

C:\Users\myuser\Downloads\openssl-OpenSSL_1_1_1d\openssl-OpenSSL_1_1_1d>echo %path%
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\bin\HostX86\x86;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\VC\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x86;C:\Program Files (x86)\Windows Kits\10\bin\x86;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\\MSBuild\Current\Bin;C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\;C:\Perl\site\bin;C:\Perl\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;D:\r2\java\jdk1.7.0_79\bin;C:\Users\myuser\Downloads\ReTools\platform-tools\;C:\Users\myuser\Downloads\ReTools\SysinternalsSuite;C:\Program Files\Git\cmd;C:\Users\myuser\AppData\Local\Microsoft\WindowsApps;;C:\Users\myuser\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja;C:\Program Files (x86)\NASM

C:\Users\myuser\Downloads\openssl-OpenSSL_1_1_1d\openssl-OpenSSL_1_1_1d>echo %lib%
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\ATLMFC\lib\x86;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\lib\x86;C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\ucrt\x86;C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x86;

C:\Users\myuser\Downloads\openssl-OpenSSL_1_1_1d\openssl-OpenSSL_1_1_1d>

 

你可能感兴趣的:(Windows 编译 openssl)