openssl 编译
openssl 编译
该文介绍 openssl 编译。
openssl 编译
1. Windows
1.1. 下载
1.1.1. 最新版本
官网:https://openssl-library.org/source/
Github:https://github.com/openssl/openssl
1.1.2. 历史版本
官网:https://openssl-library.org/source/old/index.html
1.2. 环境
编译环境1
- Visual Studio 2022
- Strawberry Perl
- NASM
VS2022 默认以 MSVC143 编译如果想要指定版本需要在 Visual Studio Install 下载对应的 MSVC,VS2022 最低支持 VS2015 MSVC140,下图是下载 VS2017 MSVC141 的编译工具链。
| Visual Studio 版本 | VC 版本(MSVC 版本) | 内部版本号(_MSC_VER) |
|---|---|---|
| Visual Studio 2022 | VC 17 (MSVC 14.3x) | 1930+ (e.g., 1931, 1932) |
| Visual Studio 2019 | VC 16 (MSVC 14.2x) | 1920+ (e.g., 1928, 1929) |
| Visual Studio 2017 | VC 15 (MSVC 14.1x) | 1910+ (e.g., 1911, 1916) |
| Visual Studio 2015 | VC 14 (MSVC 14.0) | 1900 |
Strawberry Perl 和 NASM 直接下载安装就可以了,确保 Perl 和 NASM 都在您的 %PATH% 上。
1.3. 编译
1
2
# 使用 VC141 x86
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x86 -vcvars_ver=14.1
其中 2022 是版本,Community 是类型,x86 指定 32 位,-vcvars_ver=14.1 指定 MSVC141。
1
2
3
4
5
6
7
8
9
# 编译 x86 Release
perl Configure VC-WIN32 no-tests --prefix=C:\OpenSSL\x86_Release --openssldir=C:\OpenSSL\x86_Release
nmake
nmake install
# 编译 x86 Debug
perl Configure VC-WIN32 no-shared no-tests --debug --prefix=C:\OpenSSL\x86_Debug --openssldir=C:\OpenSSL\x86_Debug
nmake
nmake install
编译 64 位和指定版本
1
2
3
4
5
6
7
8
9
10
11
12
# 使用 VC141 x64
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 -vcvars_ver=14.1
# 编译 x64 Release
perl Configure VC-WIN64A no-tests --prefix=C:\OpenSSL\x64_Release --openssldir=C:\OpenSSL\x64_Release
nmake
nmake install
# 编译 x64 Debug
perl Configure VC-WIN64A no-tests --debug --prefix=C:\OpenSSL\x64_Debug --openssldir=C:\OpenSSL\x64_Debug
nmake
nmake install
| 参数 | 说明 |
|---|---|
no-shared | 生成静态库 |
参考
本文由作者按照 CC BY 4.0 进行授权
