编译环境:Win10 + Visual Studio 2019
一、编译OpenSSL
openssl下载地址:openssl/openssl
1.1 编译
以编译64位为例,假设openssl源码放在c:ddksampleopenssl。
开始菜单中“以管理员身份运行”“x64 Native Tools Command Prompt for VS 2019”
cd c:ddksampleopenssl
perl Configure VC-WIN64A
nmake depend
nmake install_dev
注:32位时,相关步骤改为“x86 Native Tools Command Prompt for VS 2019”、“perl Configure VC-WIN32”
成功后便会生成C:Program FilesOpenSSL目录,该目录下三个子目录:bin、include和lib。
1.2 不以管理员身份运行或如何把编译结果放到自定义目录
如果不是以管理员身份运行,在nmake install_dev步骤,编译出libcrypto-3.dll、libssl-3.dll后会报下面错误。
*** Installing runtime libraries
Can't Open C:/Program Files/OpenSSL/bin/libcrypto-3.dll at .utilcopy.pl line 69.
NMAKE : fatal error U1077: 'if' : return code '0xd'
Stop.
根据信息进入<openssl>/Configurations/windows-makefile.tmpl,错误是发生在下面代码中的copy.pl $(INSTALL_SHLIBS)时。
<openssl>Configurationswindows-makefile.tmpl
install_runtime_libs: build_libs
@if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
@$(ECHO) &