====== 3.1 Windows x64 Build ====== This guide walks you step by step through building OpenSSL for Windows 64-bit. ---- ===== Prerequisites ===== Make sure all tools are installed: * ☑ Visual Studio 2022 with C++ workload * ☑ Strawberry Perl * ☑ NASM (recommended) * ☑ OpenSSL source code in ''D:\Projects\openssl-3.6.0\src'' → [[.:vorbereitung:start|1. Preparation]] → [[.:quellen:start|2. Sources]] ---- ===== Option A: PowerShell Script (recommended) ===== The build script automates all steps: # Start build (from any directory) powershell.exe -ExecutionPolicy Bypass -File "D:\Projects\openssl-3.6.0\build_openssl.ps1" The script: - Loads Visual Studio environment - Sets PATH for Perl and NASM - Configures OpenSSL - Compiles the code - Installs to ''D:\Projects\openssl-3.6.0\bin'' → Continue to [[.:testen:start|4. Testing]] ---- ===== Option B: Manual Build ===== If you want to understand each step: ==== Step 1: Load Visual Studio Environment ==== Open a **normal CMD** (not PowerShell!) and run: REM Adjust path: Community, Professional, or Enterprise call "%ProgramFiles%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat" **What happens here?** ''vcvars64.bat'' sets important environment variables: * ''PATH'' - Path to ''cl.exe'', ''link.exe'', ''nmake.exe'' * ''INCLUDE'' - Path to header files * ''LIB'' - Path to libraries **Verification:** cl Expected output: Microsoft (R) C/C++ Optimizing Compiler Version 19.xx.xxxxx for x64 ==== Step 2: Set PATH for Perl and NASM ==== set PATH=C:\Strawberry\perl\bin;%LOCALAPPDATA%\bin\NASM;%PATH% **Verification:** perl -v nasm -v ==== Step 3: Change to Source Directory ==== cd /d D:\Projects\openssl-3.6.0\src ==== Step 4: Configure OpenSSL ==== perl Configure VC-WIN64A --prefix=D:\Projects\openssl-3.6.0\bin --openssldir=D:\Projects\openssl-3.6.0\bin\ssl **Explanation:** | Parameter | Meaning | |-----------|---------| | ''VC-WIN64A'' | Visual C++, Windows 64-bit, AMD64 architecture | | ''--prefix=...'' | Where the finished files are installed | | ''--openssldir=...'' | Where configuration files are stored | **Output (example):** Configuring OpenSSL version 3.6.0 for target VC-WIN64A Using os-specific seed configuration Creating configdata.pm Running configdata.pm Creating makefile ********************************************************************** *** *** *** OpenSSL has been successfully configured *** *** *** *** Configuration summary *** *** *** ********************************************************************** ==== Step 5: Compile ==== nmake **Duration:** 10-30 minutes depending on hardware. Be patient! **What happens?** - Perl generates C code from templates - The C compiler compiles all source files - The linker creates the DLLs and EXEs **Error?** → [[.:.:troubleshooting|Troubleshooting]] ==== Step 6: Install ==== nmake install_sw ''install_sw'' installs only software (without documentation). For everything: ''nmake install'' ---- ===== Result ===== After successful build you'll find in ''D:\Projects\openssl-3.6.0\bin'': bin\ ├── bin\ │ ├── openssl.exe # Command line tool │ ├── libcrypto-3-x64.dll # Cryptography library │ └── libssl-3-x64.dll # TLS library ├── include\ │ └── openssl\ # Headers for C/C++ development ├── lib\ │ ├── libcrypto.lib # Import library for linker │ ├── libssl.lib │ └── ossl-modules\ # Provider modules (default, legacy) └── ssl\ └── openssl.cnf # OpenSSL configuration ---- ===== Quick Verification ===== D:\Projects\openssl-3.6.0\bin\bin\openssl.exe version -a Expected output: OpenSSL 3.6.0 11 Feb 2025 (Library: OpenSSL 3.6.0 11 Feb 2025) built on: ... platform: VC-WIN64A options: bn(64,64) compiler: cl /Zi /Fdossl_static.pdb /Gs0 /GF /Gy /MD /W3 ... ---- ===== Complete PowerShell Script ===== If you want to create the build script yourself: # build_openssl.ps1 - OpenSSL 3.6.0 Build Script $ErrorActionPreference = "Stop" Write-Host "========================================" -ForegroundColor Cyan Write-Host "OpenSSL 3.6.0 Build Script" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan # Paths $projectRoot = "D:\Projects\openssl-3.6.0" $srcDir = "$projectRoot\src" $binDir = "$projectRoot\bin" $vsPath = "C:\Program Files\Microsoft Visual Studio\2022\Community" $vcvarsPath = "$vsPath\VC\Auxiliary\Build\vcvars64.bat" # Load Visual Studio environment Write-Host "`n[1/5] Loading Visual Studio environment..." -ForegroundColor Yellow $pinfo = New-Object System.Diagnostics.ProcessStartInfo $pinfo.FileName = "cmd.exe" $pinfo.RedirectStandardOutput = $true $pinfo.UseShellExecute = $false $pinfo.Arguments = "/c `"`"$vcvarsPath`" && set`"" $p = New-Object System.Diagnostics.Process $p.StartInfo = $pinfo $p.Start() | Out-Null $output = $p.StandardOutput.ReadToEnd() $p.WaitForExit() $output -split "`r`n" | ForEach-Object { if ($_ -match "^([^=]+)=(.*)$") { [Environment]::SetEnvironmentVariable($matches[1], $matches[2], "Process") } } # Set PATH Write-Host "[2/5] Setting PATH for Perl and NASM..." -ForegroundColor Yellow $env:PATH = "C:\Strawberry\perl\bin;$env:LOCALAPPDATA\bin\NASM;$env:PATH" # Change to source directory Set-Location $srcDir # Delete old makefile if (Test-Path "makefile") { Remove-Item "makefile" -Force } # Configure Write-Host "[3/5] Configuring OpenSSL..." -ForegroundColor Yellow & perl Configure VC-WIN64A --prefix=$binDir --openssldir=$binDir\ssl if ($LASTEXITCODE -ne 0) { throw "Configure failed!" } # Compile Write-Host "[4/5] Compiling OpenSSL..." -ForegroundColor Yellow & nmake if ($LASTEXITCODE -ne 0) { throw "nmake failed!" } # Install Write-Host "[5/5] Installing..." -ForegroundColor Yellow & nmake install_sw if ($LASTEXITCODE -ne 0) { throw "Installation failed!" } Write-Host "`n========================================" -ForegroundColor Green Write-Host "BUILD SUCCESSFUL!" -ForegroundColor Green Write-Host "Binaries in: $binDir" -ForegroundColor Green Write-Host "========================================" -ForegroundColor Green ---- ===== Continue to ===== * [[.:testen:start|4. Testing - Verify Installation]] * [[.:integration:start|5. Integration - Integrate into .NET]] * [[.:.:troubleshooting|Troubleshooting - Solve Problems]] ---- //Wolfgang van der Stille @ EMSR DATA d.o.o. - Post-Quantum Cryptography Professional//