Summary
Spent some time recently figuring out how to build OpenSSL for 32-bit and 64-bit Windows. Wanted to get away from using pre-built libraries with additional dependencies on old versions of the Microsoft Redistributables. This is how I built the static versions of OpenSSL on Windows.
I started with the following:
- Create two directories, one for 32-bit, the other for 64-bit:
cd C:\src
md OpenSSL
cd OpenSSL
md openssl-1.0.2a-32bit
md openssl-1.0.2a-64bit
- Copy the OpenSSL source code tree into each of the newly-created directories.
Build the 64-bit release version:
- Open a VS2013 x64 Cross Tools Command Prompt window.
- Run the following commands:
cd openssl-1.0.2a-64bit
perl Configure VC-WIN64A --prefix=C:\src\OpenSSL\Build-VC-64-release
ms\do_win64a.bat
nmake -f ms\nt.mak clean
nmake -f ms\nt.mak
nmame -f ms\nt.mak install
Build the 64-bit debug version:
- In a text editor, open ms/nt.mak and replace all occurrences of /Zi with /Z7 except on the line starting with ASM.
- Open a VS2013 x64 Cross Tools Command Prompt window.
- Run the following commands:
cd openssl-1.0.2a-64bit
perl Configure debug-VC-WIN64A --prefix=C:\src\OpenSSL\Build-VC-64-debug
ms\do_win64a.bat
nmake -f ms\nt.mak clean
nmake -f ms\nt.mak
nmame -f ms\nt.mak install
Build the 32-bit release version:
- Open a VS2013 x86 Native Tools Command Prompt window.
- Run the following commands:
cd openssl-1.0.2a-32bit
perl Configure VC-WIN32 no-asm --prefix=C:\src\OpenSSL\Build-VC-32-release
ms\do_ms.bat
nmake -f ms\nt.mak clean
nmake -f ms\nt.mak
nmake -f ms\nt.mak install
Build the 32-bit debug version:
- In a text editor, open ms/nt.mak and replace all occurrences of /Zi with /Z7 except on the line starting with ASM.
- Open a VS2013 x86 Native Tools Command Prompt window.
- Run the following commands:
cd openssl-1.0.2a-32bit
perl Configure debug-VC-WIN32 no-asm --prefix=C:\src\OpenSSL\Build-VC-32-debug
ms\do_ms.bat
nmake -f ms\nt.mak clean
nmake -f ms\nt.mak
nmake -f ms\nt.mak install
Verify the libraries were built correctly:
- Run the following commands:
cd Build-VC-32-debug\lib
dumpbin /headers libeay32.lib | more
dumpbin /headers ssleay32.lib | more
- The very first line of the file header should indicate if the library is for x86 or AMD64.
- Repeat for all of the build types (release and debug, 32 and 64).
The static
.lib files can then be linked directly into other projects.