windows nmake 編譯和安裝 openssl
本文提供了在Windows環境下安裝OpenSSL的詳細步驟,包括下載Perl、NASM和VisualStudio,配置環境變量,使用PerlConfigure設置平臺,通過nmake進行編譯、測試和安裝。整個過程涉及32位和64位版本的選擇,以及針對WindowsonArm的特定版本。安裝完成后,通過opensslversion命令驗證安裝成功。
openssl 下載
官網:https://www.openssl.org/ 下載地址:https://github.com/openssl/openssl/tree/openssl-3.0.15
1.進入官網
2.Downloads
3. github 下載
4. 選擇需要的版本進行下載
5. 這里選中的是3.0.15版本,根據自己需要選擇相應的版本;
注意:由于Windows 源碼編譯安裝openssl 需要用到perl工具以及匯編工具NASM,所以需要安裝perl和NASM。
Quick start
1.Install Perl
2.Install NASM
3.Make sure both Perl and NASM are on your %PATH%
4.Use Visual Studio Developer Command Prompt with administrative privileges, choosing one of its variants depending on the intended
rchitecture. Or run cmd and execute vcvarsall.bat with one of the options x86, x86_amd64, x86_arm, x86_arm64, amd64, amd64_x86,
amd64_arm, or amd64_arm64. This sets up the environment variables needed for nmake.exe, cl.exe, etc. See also
https://docs.microsoft.com/cpp/build/building-on-the-command-line
5.From the root of the OpenSSL source directory enter
perl Configure VC-WIN32 if you want 32-bit OpenSSL or
perl Configure VC-WIN64A if you want 64-bit OpenSSL or
perl Configure VC-WIN64-ARM if you want Windows on Arm (win-arm64) OpenSSL or
perl Configure to let Configure figure out the platform
6.nmake
7.nmake test
8.nmake install
Perl 下載與安裝
- 官網:https://strawberryperl.com/
- 根據自己電腦系統,選則對應的32bit/64bit ZIP壓縮包,下載后解壓到合適目錄,并配置系統環境變量 。
NASM 下載與安裝
官網:https://www.nasm.us/
- 選擇最新版本即可
- 選擇最新版本windows64版本zip壓縮包,這里是2.16.03。下載后解壓到合適目錄,并配置系統環境變量;
Visual Studio 下載與安裝
官網:https://visualstudio.microsoft.com/zh-hans/
安裝過程不贅述。
注意:選擇組件是需要選上 “使用C++的桌面開發”,因為里面包含了nmake工具
完成以上準備操作后,接下來開始編譯安裝openssl
1.打開 visual studio 2022 命令行:
2.進入 oppensl 源碼路徑
參考以下提示,對應自己的機型;
5.From the root of the OpenSSL source directory enter
perl Configure VC-WIN32 if you want 32-bit OpenSSL or
perl Configure VC-WIN64A if you want 64-bit OpenSSL or
perl Configure VC-WIN64-ARM if you want Windows on Arm (win-arm64) OpenSSL or
perl Configure to let Configure figure out the platform
例如需要64位系統的openssl,輸入 perl Configure VC-WIN64A,然后回車運行即可;