15

I'm compiling OpenSSL with Visual Studio 2015. I have installed:

  1. Visual Studio 2015 on Windows 10.

  2. ActivePerl-5.24.0.2400-MSWin32-x64-300558.

  3. nasm-2.11.08-win32.

  4. OpenSSL source code by git clone git://git.openssl.org/openssl.git

What I did are:

  1. Create a batch file with lines below.

    @call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64
    @set path=%path%;C:\Users\gchen\AppData\Local\nasm
    
  2. perl Configure VC-WIN64A —prefix=C:\test\openssl

Now I should do ms\do_win64a, but I can't find this batch file. In the directory ms, there are files

2016/08/22  17:39    <DIR>          .    
2016/08/22  17:39    <DIR>          ..    
2016/08/21  14:23             3,646 applink.c    
2016/08/21  14:23             1,247 cmp.pl    
2016/08/21  14:23             2,815 segrenam.pl    
2016/08/21  14:23             4,541 tlhelp32.h    
2016/08/21  14:23             1,137 uplink-common.pl    
2016/08/21  14:23             1,472 uplink-ia64.pl    
2016/08/21  14:23             1,111 uplink-x86.pl   
2016/08/21  14:23             1,594 uplink-x86_64.pl   
2016/08/21  14:23             4,225 uplink.c   
2016/08/21  14:23             2,268 uplink.h

but there is no ms-win64a.bat.

What did I do wrong?

jww
  • 83,594
  • 69
  • 338
  • 732
gchen2101
  • 161
  • 1
  • 1
  • 6

3 Answers3

37

The build process has changed with the new 1.1.0 release. Probably you already figured out yourself, but anyway:

Starting with 1.1.0 there are no ms\do_*.bat files anymore.

Instead execute the following steps:

x32 compilation on Windows:

perl Configure VC-WIN32
nmake
nmake test

x64A compilation on Windows:

perl Configure VC-WIN64A
nmake
nmake test

Configure your Compiler environment as before and point your path to Perl (and NASM if used).

Source: The INSTALL file included in the 1.1.0 release.

Frederik Winkelsdorf
  • 3,473
  • 24
  • 36
  • 1
    As you said, I have figured out the problem. Your answer makes me feel good. – gchen2101 Sep 02 '16 at 06:13
  • As you said, I have figured out the problem. Anyhow your answer makes me feel good. At the beginning, I used Active Perl. I got warning saying that can't find nmake. But I know VC nmake.exe is in the PATH. I switch to StrawPerl, which works fine. – gchen2101 Sep 02 '16 at 07:09
  • Make sure that you are running everything as Administrator –  Oct 17 '17 at 21:43
3

Since the new 1.1.0 release there is no ms\ folder in the source code. And if you wonder what should you edit to build a static version nowadays (which results in a single .exe file without any DLLs). Here is the full guide.

You will need the following prerequisites:

You are expected to install all those tools system-wide and add them to your %PATH% environmental variable.

After you got everything we need, just follow this simple steps:

  1. Open VS2015 x64 Native Tools Command Prompt from your Start Menu. You will see command prompt.
  2. Create C:\build directory and issue the following command in the command prompt:

    • cd c:\build
  3. Download latest zlib & OpenSSL source codes to your build dir by using the following commands:

    • git clone https://github.com/madler/zlib
    • git clone https://github.com/openssl/openssl
  4. First we have to build static zlib. To do that first we will need to edit some configuration files:

    • Navigate to the zlib source folder: cd C:\build\zlib
    • Edit the win32\Makefile.msc file:

      1. Find the line starting with CFLAGS
      2. Replace -MD with -GL -MT -Zc:wchar_t-
      3. Find the line starting with LDFLAGS
      4. Replace -debug with -opt:icf -dynamicbase -nxcompat -ltcg /nodefaultlib:msvcrt
  5. Build zlib using the following command (should take less than a minute):

    • nmake -f win32/Makefile.msc AS=ml64 LOC="-DASMV -DASMINF -DNDEBUG -I." OBJA="inffasx64.obj gvmat64.obj inffas8664.obj"
  6. Copy resulting files to your OpenSSL directory:

    • xcopy zlib.h C:\build\openssl\
    • xcopy zconf.h C:\build\openssl\
    • xcopy zlib.lib C:\build\openssl\
    • xcopy zlib.pdb C:\build\openssl\
  7. Navigate to OpenSSL source: cd C:\build\openssl\ and configure it to use static zlib & read configuration files (openssl.cnf) from C:\Windows\ directory.

    • perl Configure VC-WIN64A no-shared zlib no-zlib-dynamic threads --prefix=C:\Windows\
  8. Now make the following edits to the C:\build\openssl\makefile:

    • Find the line that starts with: CFLAG
    • Append: /Zc:wchar_t- /GL /Zi
    • Find the line that starts with: LDFLAGS
    • Replace /debug with /incremental:no /opt:icf /dynamicbase /nxcompat /ltcg /nodefaultlib:msvcrt
    • Find the line that starts with: EX_LIBS
    • Replace ZLIB1 with zlib.lib
    • Save changes
  9. Build OpenSSL by issuing the nmake command (will take around 15 minutes).

The resulting ~3MB openssl.exe file will be located at C:\build\openssl\apps\ directory. It is fully portable, since all DLLs are included. If you need to use custom configuration file, copy C:\build\openssl\apps\openssl.cnf to your C:\Windows\ directory & edit it to your liking.

Anubioz
  • 335
  • 3
  • 10
0

The following commands need to be executed under the administrator user

  1. perl Configure VC- WIN64A --prefix=C:\Build-OpenSSL-VC32-Debug-DLL
  2. nmake -f makefile
  3. nmake install

Starting with 1.1.0 there is no need of executed ms\do_*.bat files anymore.

Dev Khadka
  • 4,361
  • 3
  • 16
  • 31
acreil
  • 1