Build Openssl with Visual Studio and NASM

We’ve talked about how to build openssl with msys2 and Mingw. Today, I will talk about how to build openssl with Visual Studio 2017 and NASM.

step1: download/install required software

You can download openssl source code from its official website. We’ll download openssl-1.1.1s to build. Download and install strawberry perl. Don’t use ActiveState perl which requires login and behaviors like┬árogue app. Download and install nasm. Add the path to perl.exe and nasm.exe to PATH environment variable.

step2: configure and build

We’ll build openssl for x64 (64bit) so open a x64 Native Tools Command Prompt for VS 2017(you can find the menu item under the VS 2017 menu in start menu). Run the following commands in order:

perl Configure VC-WIN64A --prefix=d:\openssl-1.1.1s --openssldir=d:\openssl-1.1.1s
nmake install

If you need to build 32bit openssl, change the configure command to

perl Configure VC-WIN32 --prefix=d:\openssl-1.1.1s --openssldir=d:\openssl-1.1.1s

Note that you’d better specify the –prefix and –openssldir parameters and let them point to the same location, the directory you install built openssl binaries, libs, and header files to. If you don’t specify the two parameters, it will install openssl to C:\Program Files\OpenSSL by default, but you may have no privilege to install an application to that protected directory. I don’t know the difference between –prefix and –openssldir, and I don’t know what is done under the hood using these two parameters, just keep them the same.

Leave a Reply