# OpenSSL static linking environment setup script # For Tauri build with static OpenSSL linking [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 $ErrorActionPreference = "Continue" # OpenSSL installation path (OpenSSL-Win64 FULL version) $OpenSSLDir = "C:\Program Files\OpenSSL-Win64" $OpenSSLLibDir = "C:\Program Files\OpenSSL-Win64\lib\VC\x64\MT" $OpenSSLIncludeDir = "C:\Program Files\OpenSSL-Win64\include" # Check if OpenSSL is installed if (-not (Test-Path $OpenSSLDir)) { Write-Host "[WARN] OpenSSL-Win64 not found at default location: $OpenSSLDir" -ForegroundColor Yellow Write-Host "[WARN] Trying other locations..." -ForegroundColor Yellow # Try other possible paths $possiblePaths = @( "C:\Program Files\OpenSSL-Win64", "C:\Program Files (x86)\OpenSSL-Win64", "C:\OpenSSL-Win64" ) foreach ($path in $possiblePaths) { if (Test-Path $path) { $OpenSSLDir = $path $OpenSSLLibDir = "$path\lib\VC\x64\MT" $OpenSSLIncludeDir = "$path\include" Write-Host "[OK] Found OpenSSL: $path" -ForegroundColor Green break } } } # Set environment variables (static linking OpenSSL) $env:OPENSSL_DIR = $OpenSSLDir $env:OPENSSL_LIB_DIR = $OpenSSLLibDir $env:OPENSSL_INCLUDE_DIR = $OpenSSLIncludeDir $env:OPENSSL_STATIC = "1" # Set C runtime static linking (generate truly standalone exe) $env:RUSTFLAGS = "-C target-feature=+crt-static" Write-Host "========================================" -ForegroundColor Cyan Write-Host "OpenSSL static linking environment configured" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "OPENSSL_DIR: $env:OPENSSL_DIR" Write-Host "OPENSSL_LIB_DIR: $env:OPENSSL_LIB_DIR" Write-Host "OPENSSL_INCLUDE_DIR: $env:OPENSSL_INCLUDE_DIR" Write-Host "OPENSSL_STATIC: $env:OPENSSL_STATIC" Write-Host "RUSTFLAGS: $env:RUSTFLAGS" Write-Host "" # Check if static libraries exist $libcryptoPath = Join-Path $OpenSSLLibDir "libcrypto_static.lib" $libsslPath = Join-Path $OpenSSLLibDir "libssl_static.lib" if ((Test-Path $libcryptoPath) -and (Test-Path $libsslPath)) { Write-Host "[OK] OpenSSL static libraries found" -ForegroundColor Green Write-Host " - $libcryptoPath" Write-Host " - $libsslPath" } else { Write-Host "[WARN] OpenSSL static libraries not found" -ForegroundColor Yellow Write-Host " Expected: $libcryptoPath" Write-Host " Expected: $libsslPath" Write-Host "[INFO] Will use vendored OpenSSL (takes longer to compile)" -ForegroundColor Yellow # Clear manual path settings, let openssl crate use vendored $env:OPENSSL_DIR = $null $env:OPENSSL_LIB_DIR = $null $env:OPENSSL_INCLUDE_DIR = $null } Write-Host ""