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
    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/do_ms.sh
    perl util/mkfiles.pl >MINFO
    perl util/mk1mf.pl no-asm VC-WIN32 > ms/nt.mak
    perl util/mk1mf.pl dll no-asm VC-WIN32 > ms/ntdll.mak
    perl util/mkdef.pl 32 libeay > ms/libeay32.def
    perl util/mkdef.pl 32 ssleay > ms/ssleay32.def
    ^D
  8. Launch the shell script you just created
    ms/do_ms.sh
  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.

About paolog

homo technologicus cynicus
This entry was posted in C, Howtos. Bookmark the permalink.

10 Responses to Howto build openssl on Windows

  1. John A. Holt says:

    Excellent HOWTO. This saved me hours of work.

  2. Shantou says:

    Hi Paolog,

    Thanks for this blog. But I don’t see “Util” folder in openSSL 1.0.1c package. Any idea?

  3. paolog says:

    What about lowercase util as in openssl-1.0.1c/util ?

  4. Shantou says:

    It is strange that there is no util/Util folder in 1.0.1c package.
    I do see it in other packages such as 0.9.6c, 0.9.6k, 0.9.7b and 1.0.0d.

  5. paolog says:

    Get once again your OpenSSL sources from here: http://openssl.org/source/ then extract them using a good tool such as 7zip.
    There is no uppercase Util directoly anywhere in any of the packages you mention. This uppercase Util is also not mentioned in this howto.

  6. Shantou says:

    Paolog, I re-downloaded the package, and extracted it using WinRar. Now I can see the util folder. Thanks for your help.

  7. J Trades says:

    I need to compile a 64-bit version. Any ideas?

  8. paolog says:

    Hi J.T.,

    I have never tried that myself. I’d say, at step 3, Open the 64 bit Visual Studio 2011 Developer Command Prompt.

    Then every time there is a 32 in the scripts, replace that with 64, as in “perl Configure VC-WIN32” => “perl Configure VC-WIN64”.

    The big question is: is that architecture supported ? I don’t know for sure.

  9. Bruce Cran says:

    “Visual Studio 2011 beta”

    Did you mean Visual Studio 2012 beta? Or maybe Visual Studio 11 beta?

  10. paolog says:

    Sure ! That was a typo

Leave a Reply

Your email address will not be published. Required fields are marked *

Anti-Spam Quiz: