Briefly
OpenSSL is an open source third-party library that implements the SSL (Secure SocketLayer) and TLS (Transport Layer Security) protocols and is used by a wide range of enterprise applications. For the average developer, downloading the compiled OpenSSL library on Win32 OpenSSL is a good way to save effort and trouble. For advanced development users, OpenSSL may need to be modified or tailored appropriately, so compiling it becomes a critical issue.
The following, mainly describes how to compile the OpenSSL library on Windows.
Environmental preparation
Download and install Visual Studio (take VS 2015 as an example).
Download and install ActivePerl.
Download address: http://www.activestate.com/activeperl/downloads
I downloaded: ActivePerl-5.26.0.2600-MSWin32-x64-403866.exeOpen a command prompt, navigate to the
D:\Program Files\Perl\eg
directory, and executeperl example.pl
, if promptedHello from ActivePerl!
, the Perl installation is successful:Download and install the Nasm assembler and
D:\Program Files\NASM
add it to the system environment variable Path.
Download address: http://www.nasm.us/
I downloaded: nasm-2.13.01-installer-x64.exeDownload and install OpenSSL
Download address: http://www.openssl.org/
I downloaded: openssl-1.0.2m.tar.gzComplete all the above steps, unzip the OpenSSL package to
E:\openssl-1.0.2m
, and you are ready to compile.Note: There are two files in the unzipped directory - INSTALL.W32, INSTALL.W64, which contain the various compilation steps of OpenSSL.
Compilation step
Open a command prompt and navigate to
E:\openssl-1.0.2m
:Enter
perl Configure VC-WIN32 --prefix=E:\OpenSSL
(install it intoE:\OpenSSL
):Enter
ms\do_nasm
:Navigate to the command prompt
D:\Program Files\Microsoft Visual Studio 14.0\VC\bin
and entervcvars32.bat
:Without this step, a series of errors such as nmake is not an internal or external command will be prompted.
Navigate to the command prompt again
E:\openssl-1.0.2m
and enternmake -f ms\ntdll.mak
:After completion,
openssl-1.0.2m
a folder named out32dll will be generated in the directory, which contains some dynamic libraries and exe files:Input
nmake -f ms\ntdll.mak test
, if it is finally displayedpassed all tests
, the generated library is correct:Enter
nmake -f ms\ntdll.mak install
:After completion,
E:\OpenSSL
four folders of bin, include, lib, and ssl will be generated in the directory:
Notice:
VC-WIN32
The above compilation is the release version, if you want to compile the debug version, you can change the above step 2debug-VC-WIN32
to.- To compile a static library, just
ms\nt.mak
replace the one used above withms\ntdll.mak
. - To generate a library without assembly support, you need to replace steps 2 and 3 above with
perl Configure VC-WIN32 no-asm --prefix=E:\OpenSSL
summs\do_ms
. - Include the corresponding assembly files under the
E:\openssl-1.0.2m\tmp32dll
folder.