Windows编译安装openssl

本文链接:https://www.cnblogs.com/obarong/p/13260321.html

官方不发布二进制文件,要下载源码编译

环境

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:

安装完会自动添加环境变量。

下载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

posted @ 2020-07-07 13:45  奥巴荣  阅读(6198)  评论(0编辑  收藏  举报