windows 平台编译openssl

准备环境

安装perl

下载Perl 5.40.0.1 Portable zip
strawberryperl

解压后设置系统环境变量
测试安装是否成功

perl --version

This is perl 5, version 40, subversion 0 (v5.40.0) built for MSWin32-x64-multi-thread

Copyright 1987-2024, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at https://www.perl.org/, the Perl Home Page.

安装NASM

nasm官网
nasm-2.16.03-win64

下载解压后要加入系统环境变量中

获取源码

openssl官网
openssl源码3.4.1

源码编译

配置

打开VS2019 开发人员命令提示符​

  • x64 Native Tools Command Prompt for VS 2019
  • x86 Native Tools Command Prompt for VS 2019

正确安装了VisualStudio2019的话可以在win菜单中打到,可以在win任务栏的搜索中搜到

进入openssl 源码目录

E:
cd E:\openssl\openssl-3.4.1

# 64位动态库(默认)
perl Configure VC-WIN64A --prefix=D:\openssl-output
# 32位静态库(无汇编优化)
perl Configure VC-WIN32 no-asm --prefix=D:\openssl-output[2,7](@ref)

​关键参数说明:

  • –prefix:指定输出目录(默认安装到系统路径)。
  • no-asm:禁用汇编优化(避免 NASM 依赖问题)。
  • no-shared:生成静态库(.lib 而非 .dll)。

使用64位编译,输出

perl Configure VC-WIN64A --prefix=D:\openssl-output
Configuring OpenSSL version 3.4.1 for target VC-WIN64A
Using os-specific seed configuration
Created configdata.pm
Running configdata.pm
Created makefile.in
Created makefile
Created include\openssl\configuration.h

**********************************************************************
***                                                                ***
***   OpenSSL has been successfully configured                     ***
***                                                                ***
***   If you encounter a problem while building, please open an    ***
***   issue on GitHub <https://github.com/openssl/openssl/issues>  ***
***   and include the output from the following command:           ***
***                                                                ***
***       perl configdata.pm --dump                                ***
***                                                                ***
***   (If you are new to OpenSSL, you might want to consult the    ***
***   'Troubleshooting' section in the INSTALL.md file first)      ***
***                                                                ***
**********************************************************************

编译

然后可以nmake

nmake      # 仅编译
nmake test # 运行测试(可选,确保功能正常)
nmake install  # 安装到 --prefix 指定目录[3,8](@ref)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

tadus_zeng

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值