Compiling OpenSSL under Windows

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

  1. Download and install Visual Studio (take VS 2015 as an example).

  2. Download and install ActivePerl. 
    Download address: http://www.activestate.com/activeperl/downloads 
    I downloaded: ActivePerl-5.26.0.2600-MSWin32-x64-403866.exe

    Open a command prompt, navigate to the  D:\Program Files\Perl\eg directory, and execute  perl example.pl, if prompted  Hello from ActivePerl! , the Perl installation is successful:

    write picture description here

  3. 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.exe

  4. Download and install OpenSSL 
    Download address: http://www.openssl.org/ 
    I downloaded: openssl-1.0.2m.tar.gz

    Complete 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

  1. Open a command prompt and navigate to  E:\openssl-1.0.2m:

    write picture description here

  2. Enter  perl Configure VC-WIN32 --prefix=E:\OpenSSL(install it into  E:\OpenSSL):

    write picture description here

  3. Enter  ms\do_nasm:

    write picture description here

  4. Navigate to the command prompt  D:\Program Files\Microsoft Visual Studio 14.0\VC\binand enter vcvars32.bat:

    write picture description here

    Without this step, a series of errors such as nmake is not an internal or external command will be prompted.

  5. Navigate to the command prompt again  E:\openssl-1.0.2mand enter  nmake -f ms\ntdll.mak:

    write picture description here

    After completion,  openssl-1.0.2m a folder named out32dll will be generated in the directory, which contains some dynamic libraries and exe files:

    write picture description here

  6. Input  nmake -f ms\ntdll.mak test, if it is finally displayed  passed all tests , the generated library is correct:

    write picture description here

  7. Enter  nmake -f ms\ntdll.mak install:

    write picture description here

    After completion,  E:\OpenSSL four folders of bin, include, lib, and ssl will be generated in the directory:

    write picture description here

Notice:

  • VC-WIN32 The above compilation is the release version, if you want to compile the debug version, you can change  the above step 2  debug-VC-WIN32to.
  • To compile a static library, just  ms\nt.mak replace the one used above with  ms\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 sum  ms\do_ms .
  • Include the corresponding assembly files under the  E:\openssl-1.0.2m\tmp32dll folder.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326013747&siteId=291194637