Howto build openssl on Windows

This howto is for building the latest version of openssl (1.0.1) on the latest version of the Microsoft Windows Desktop operating system (Windows 7 64 bit) using the latest Microsoft compiler (Visual Studio 2011 beta), targeting the 32 bit architecture.

  1. Get OpenSSL 1.0.1

  2. Get the latest package of git for windows (this includes perl which we need)

  3. Open the Visual Studio 2011 Developer Command Prompt

  4. Launch sh from git-msys (look for the your correct command by inspecting the Git bash link):

    C:\Windows\SysWOW64\cmd.exe /c ""C:\Program Files (x86)\Git\bin\sh.exe" --login -i"
  5. Move to the folder where you have extracted the openssl source archive

    cd Desktop/openssl-1.0.1/
  6. Run autoconfig and prepare make files; ignore the prefix; the sample below only builds suffort for a few ciphers: aes md5 rc4 rsa sha mac md2

    perl Configure VC-WIN32 -DOPENSSL_NO_HW no-asm no-static-engine no-bf no-cast no-des no-dh no-dsa no-mdc2 no-rc2 no-rc5 no-capieng --prefix=c:/some/openssl/dir
  7. Create a shell script to emulate the ms/do_ms.bat batch file:

    cat > ms/
    perl util/ >MINFO
    perl util/ no-asm VC-WIN32 > ms/nt.mak
    perl util/ dll no-asm VC-WIN32 > ms/ntdll.mak
    perl util/ 32 libeay > ms/libeay32.def
    perl util/ 32 ssleay > ms/ssleay32.def
  8. Launch the shell script you just created

  9. Build the static and dynamic libraries:

    nmake -f ms/nt.mak
  10. At the end of the process copy the include files openssl-1.0.1/inc32/openssl as openssl to your preferred include path, then copy the static library out32/libeay32.lib to your preferred library path.