The following sections describes how to compile OpenSSL 3.0.x for Visual Studio 2008 and higher without patented algorithms.
NASM (https://www.nasm.us/)
Perl (https://www.activestate.com/products/activeperl/)
Download the latest version of OpenSSL from here http://www.openssl.org/source/
Extract the OpenSSL tar to <SDK Installation Directory>\third-party\build_ssl.
That will create a new folder <SDK Installation Directory>\third-party\build_ssl\openssl-<version_number>.
Navigate to <SDK Installation Directory>\third-party\build_ssl and create a new file env_no_VS.bat with the following content:
@echo off
set OPENSSL_VERSION=3.0.8
PATH=C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
REM PATH for Perl
where /q "C:\Perl\bin:perl.exe"
if errorlevel 1 (
where /q "C:\Perl64\bin:perl.exe"
if errorlevel 1 (
echo perl cannot be found. please ensure it is installed and placed in your path.
pause
exit /b
) else (
PATH=C:\Perl64\bin;C:\Perl64\site\bin;%PATH%
)
) else (
PATH=C:\Perl\bin;C:\Perl\site\bin;%PATH%
)
REM PATH for NASM
where /q "C:\Program Files (x86)\NASM:nasm.exe"
if errorlevel 1 (
where /q "C:\Program Files\NASM:nasm.exe"
if errorlevel 1 (
echo nasm cannot be found. please ensure it is installed and placed in your path.
pause
exit /b
) else (
PATH=C:\Program Files\NASM;%PATH%
)
) else (
PATH=C:\Program Files ^(x86^)\NASM;%PATH%
)
SET INCLUDE=
SET LIB=
SET LIBPATH=
That will setup the environment you need to use the following build scripts.
The following example code uses paths for VS2015. For other versions of Visual Studio you need to adapt the paths. Create a folder <SDK Installation Directory>\third-party\build_ssl\vs2015. In that folder create the following batch files.
To build 32bit release libraries create the file build_win32_vs2015_release.cmd:
@echo off
setlocal
call ..\env_no_VS.bat
REM setup environment
set VS_ENV_BAT="C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat"
set BUILD_CONFIG=win32-vs2015
set CONFIG_ARCH=VC-WIN32
set REPLACE_ARCH=
set DEBUG_POSTFIX=
CALL %VS_ENV_BAT%
REM create a copy of the source dir
xcopy ..\openssl-%OPENSSL_VERSION% openssl-%BUILD_CONFIG%\ /s /e
REM set target dir
set TARGET_DIR=%cd%\openssl-%OPENSSL_VERSION%-%BUILD_CONFIG%-DLL
cd openssl-%BUILD_CONFIG%
REM prefix is the target directory
perl Configure no-idea no-mdc2 no-rc5 no-ssl3 no-deprecated %CONFIG_ARCH% --api=3.0 --prefix=%TARGET_DIR%
nmake build_libs
nmake install_dev
REM delete build directory
cd ..
RMDIR /S /Q openssl-%BUILD_CONFIG%
To build 64bit release libraries create the file build_win64_vs2015_release.cmd:
@echo off
setlocal
call ..\env_no_VS.bat
REM setup environment
set VS_ENV_BAT="C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat"
set BUILD_CONFIG=win64-vs2015
set CONFIG_ARCH=VC-WIN64A
set REPLACE_ARCH=-x64
set DEBUG_POSTFIX=
CALL %VS_ENV_BAT%
REM create a copy of the source dir
xcopy ..\openssl-%OPENSSL_VERSION% openssl-%BUILD_CONFIG%\ /s /e
REM set target dir
set TARGET_DIR=%cd%\openssl-%OPENSSL_VERSION%-%BUILD_CONFIG%-DLL
cd openssl-%BUILD_CONFIG%
REM prefix is the target directory
perl Configure no-idea no-mdc2 no-rc5 no-ssl3 no-deprecated %CONFIG_ARCH% --api=3.0 --prefix=%TARGET_DIR%
nmake build_libs
nmake install_dev
REM delete build directory
cd ..
RMDIR /S /Q openssl-%BUILD_CONFIG%
To execute all build scripts in one go create a batch file with the following content:
@echo off
call build_win32_vs2015_release.cmd
call build_win64_vs2015_release.cmd
echo Build VS2015 Done
Check if the OpenSSL version in env_no_VS.bat matches the version of OpenSSL you want to build. Edit env_no_VS.bat to set the correct version:
set OPENSSL_VERSION=3.0.8
- Open a command promp and navigate to <SDK Installation Directory>\third-party\build_ssl.
- Execute the batch file env_no_VS.bat to configure the environment.
- Enter the folder containing the build scripts e.g. vs2015
- Execute the batch file build_all.cmd to build all or execute one of the files described above to build a single configuration of OpenSSL.
Finally, you need to copy the libaries and header files to the SDK folder structure. Create a folder named
<SDK Installation Directory>\third-party\win<32/64>\vs<version>\openssl
The folder might already exist if you built with the version of Visual Studio that you installed the SDK for.
- Create a folder <SDK Installation Directory>\third-party\win<32/64>\vs<version>\openssl.
- Copy the folders bin include and lib from the build directory to the openssl folder created above