window下编译openssl

发布时间 2023-09-18 15:38:21作者: laremehpe

Building OpenSSL 1.1.1(b) Notes (Windows) · GitHub

 

Required: Visual Studio 2015 or 2017 (or probably later works)

Setup
1. Clone/download OpenSSL 1.1.1 source to a folder
2. Download / install Perl (They recommend Active perl)
   I recommend using Chocolatey so for me: choco install activeperl
3. Ensure Perl is in the system path. (Choco appears to do this by default)
4. Download / install NASM
   I recommend using Chocolatey so for me: choco install nasm
5. Ensure NASM is in the system path. (For me the directory to add was C:\Program Files\NASM)
6. Duplicate the OpenSSL folder into one for x64 and one for x86

Building Debug/Release Static/Shared x64/x86

x86
1. Open a Visual Studio Build Tools Command Prompt (Start->All Programs->Visual Studio 20**->Visual Studio Tools->VC->x86 Native Tools Command Prompt for...)
2. cd to your OpenSSL x86 folder (you created in Setup.6)
3. Run: perl Configure VC-WIN32   (add no-shared if you just want a static build)
4. Run: nmake   (this will take a bit)
5. Run: nmake test (this will take a bit too)
6. If everything went well, you have a binary in /apps and libs in the root of you x86 folder (both static and dynamic release)
7. Save off the built things you want to save (since they will be deleted in a moment)
8. Run: nmake clean
9: Run: perl Configure VC-WIN32 --debug  (add no-shared if you just want a static build)
10. Run: nmake   (this will take a bit)
11. Run: nmake test (this will take a bit too)
12. If everything went well, you have a binary in /apps and libs in the root of you x86 folder (both static and dynamic debug versions)
13. Save off the built things you want to save (I recommend putting them somewhere different from the release versions since they will have the same names)

For x64, follow the x86 steps except:
1. Replace x86 with x64 in: Steps 1,2,6,12
2. Replace VC-WIN32 with VC-WIN64A in steps 3 and 9

Note that there are (minor) differences in headers between x64 and x86 so you should save 2 include directories.