../

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.

Requirements

I started with the following:

Setup

  1. 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
  2. Copy the OpenSSL source code tree into each of the newly-created directories.

64-bit release version

Build the 64-bit release version:

  1. Open a VS2013 x64 Cross Tools Command Prompt window.
  2. 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

64-bit debug version

Build the 64-bit debug version:

  1. In a text editor, open ms/nt.mak and replace all occurrences of /Zi with /Z7 except on the line starting with ASM.
  2. Open a VS2013 x64 Cross Tools Command Prompt window.
  3. 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

32-bit release version

Build the 32-bit release version:

  1. Open a VS2013 x86 Native Tools Command Prompt window.
  2. 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

32-bit debug version

Build the 32-bit debug version:

  1. In a text editor, open ms/nt.mak and replace all occurrences of /Zi with /Z7 except on the line starting with ASM.
  2. Open a VS2013 x86 Native Tools Command Prompt window.
  3. 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

Verifying libraries

Verify the libraries were built correctly:

  1. Run the following commands:
    cd Build-VC-32-debug\lib dumpbin /headers libeay32.lib | more dumpbin /headers ssleay32.lib | more
  2. The very first line of the file header should indicate if the library is for x86 or AMD64.
  3. 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.

Last modified: 2015-04-13
Stéphane Charette, stephanecharette@gmail.com
../