官方不發布二進制文件,要下載源碼編譯
環境
Win10 64位
VS2017
openssl 1.1.1g
nasm-2.15.02
strawberry-perl-5.30.2.1-64bit
CPU:Intel
方法一
下載編譯好的openssl
http://slproweb.com/products/Win32OpenSSL.html
一般Light版本夠用了。
方法二
下載源碼,官方地址:
https://www.openssl.org/source/
解壓,到源碼目錄,查看INSTALL
下載perl:
- Strawberry Perl(推薦):比較大,下載慢。
- ActiveState Perl:缺模塊。
安裝完會自動添加環境變量。
下載nasm並添加環境變量,官方地址: https://www.nasm.us/
用管理員打開“適用於 VS 2017 的 x64 本機工具命令提示”,到openssl源碼目錄
d:
cd D:\projects\win\openssl-1.1.1g
perl Configure VC-WIN64A
nmake
nmake test
nmake install
默認安裝到C:\Program Files\OpenSSL
安裝成功
PS C:\Program Files\OpenSSL\bin> openssl version
OpenSSL 1.1.1g 21 Apr 2020
參考
Windows 下OpenSSL安裝過程及錯誤解決辦法_發呆的程序猿-CSDN博客_openssl安裝教程
https://blog.csdn.net/xuebing1995/article/details/80004638?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.edu_weight
OpenSSL 在windows系統下的編譯全解_danscort2000的專欄-CSDN博客_openssl 編譯
https://blog.csdn.net/danscort2000/article/details/81300248
問題
- 用Git的perl,初始化報錯
$ perl Configure VC-WIN64I
Configuring OpenSSL version 1.1.1g (0x1010107fL) for VC-WIN64I
Using os-specific seed configuration
******************************************************************************
This perl implementation doesn't produce Windows like paths (with backward
slash directory separators). Please use an implementation that matches your
building platform.
This Perl version: 5.26.2 for x86_64-msys-thread-multi
******************************************************************************
解:下載官方perl。
- ActiveState Perl,用powershell編譯報錯
> perl Configure VC-WIN64I
Configuring OpenSSL version 1.1.1g (0x1010107fL) for VC-WIN64I
Using os-specific seed configuration
Can't locate Win32/Console.pm in @INC (you may need to install the Win32::Console module) (@INC contains: D:/projects/win/openssl-1.1.1g/util/perl C:/Perl64/site/lib C:/Perl64/lib) at C:/Perl64/site/lib/ActivePerl/Config.pm line 400.
Compilation failed in require at C:/Perl64/site/lib/ExtUtils/MakeMaker.pm line 9.
BEGIN failed--compilation aborted at C:/Perl64/site/lib/ExtUtils/MakeMaker.pm line 9.
Compilation failed in require at C:/Perl64/site/lib/IPC/Cmd.pm line 235.
解:
用Strawberry Perl。
參考:PERL運行“Can't locate Win32/OLE.pm in INC”怎么解決_百度知道
https://zhidao.baidu.com/question/875590807540601412.html
- 添加nmake的路徑到環境變量,報錯
> nmake
Microsoft (R) 程序維護實用工具 14.16.27027.1 版
版權所有 (C) Microsoft Corporation。 保留所有權利。
"D:\tool\Strawberry\perl\bin\perl.exe" "-I." -Mconfigdata "util\dofile.pl" "-omakefile" "include\crypto\bn_conf.h.in" > include\crypto\bn_conf.h
"D:\tool\Strawberry\perl\bin\perl.exe" "-I." -Mconfigdata "util\dofile.pl" "-omakefile" "include\crypto\dso_conf.h.in" > include\crypto\dso_conf.h
"D:\tool\Strawberry\perl\bin\perl.exe" "-I." -Mconfigdata "util\dofile.pl" "-omakefile" "include\openssl\opensslconf.h.in" > include\openssl\opensslconf.h
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64\nmake.exe" / depend && "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64\nmake.exe" / _all
Microsoft (R) 程序維護實用工具 14.16.27027.1 版
版權所有 (C) Microsoft Corporation。 保留所有權利。
Microsoft (R) 程序維護實用工具 14.16.27027.1 版
版權所有 (C) Microsoft Corporation。 保留所有權利。
cl /Zi /Fdossl_static.pdb /Gs0 /GF /Gy /MD /W3 /wd4090 /nologo /O2 /I "." /I "include" -D"L_ENDIAN" -D"OPENSSL_PIC" -D"OPENSSL_CPUID_OBJ" -D"OPENSSL_BN_ASM_MONT" -D"SHA1_ASM" -D"SHA256_ASM" -D"SHA512_ASM" -D"AES_ASM" -D"GHASH_ASM" -D"OPENSSLDIR=\"C:\\Program Files\\Common Files\\SSL\"" -D"ENGINESDIR=\"C:\\Program Files\\OpenSSL\\lib\\engines-1_1\"" -D"OPENSSL_SYS_WIN32" -D"WIN32_LEAN_AND_MEAN" -D"UNICODE" -D"_UNICODE" -D"_CRT_SECURE_NO_DEPRECATE" -D"_WINSOCK_DEPRECATED_NO_WARNINGS" -D"OPENSSL_USE_APPLINK" -D"NDEBUG" -c /Foapps\app_rand.obj "apps\app_rand.c"
app_rand.c
D:\projects\win\openssl-1.1.1g\e_os.h(13): fatal error C1083: 無法打開包括文件: “limits.h”: No such file or directory
NMAKE : fatal error U1077: “"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64\cl.EXE"”: 返回代碼“0x2”
Stop.
NMAKE : fatal error U1077: “"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64\nmake.exe"”: 返回代碼“0x2”
Stop.
解:
使用“適用於 VS 2017 的 x64 本機工具命令提示”來編譯。
- nmake報錯
'ias' 不是內部或外部命令,也不是可運行的程序
或批處理文件。
NMAKE : fatal error U1077: “ias”: 返回代碼“0x1”
Stop.
NMAKE : fatal error U1077: “"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\nmake.exe"”: 返回代碼“0x2”
Stop.
解:
perl Configure VC-WIN64A
參考:[openssl-dev] [openssl.org #4630] Fatal error U1077: 'ias' : return code '0x1' on Skylake processor
https://mta.openssl.org/pipermail/openssl-dev/2016-July/008090.html