7

I am trying to build OpenSSL on Windows 7 for a work project, but I am having trouble.

The INSTALL instructions say that the easy way to do this:

Quick Start
-----------

If you want to just get on with it, do:

on Windows (only pick one of the targets for configuration):

$ perl Configure { VC-WIN32 | VC-WIN64A | VC-WIN64I | VC-CE }
$ nmake
$ nmake test
$ nmake install

I was able to run perl Configure VC-WIN64A no problem. However, when I try running nmake, I get the following output:

>C:\Users\jget952\Downloads\openssl-1.1.0f>"C:\Program Files (x86)\Microsoft >Visual Studio 14.0\VC\bin\amd64\nmake.exe"
>
>Microsoft (R) Program Maintenance Utility Version 14.00.24225.1
>Copyright (C) Microsoft Corporation.  All rights reserved.
>
>"C:\Program Files (x86)\Microsoft Visual Studio 
>14.0\VC\bin\amd64\nmake.exe" depend && "C:\Program Files (x86)\Microsoft Visual >Studio 14.0\VC\bin\amd64\nmake.exe" _all
>
>Microsoft (R) Program Maintenance Utility Version 14.00.24225.1
>Copyright (C) Microsoft Corporation.  All rights reserved.
>
>
>Microsoft (R) Program Maintenance Utility Version 14.00.24225.1
>Copyright (C) Microsoft Corporation.  All rights reserved.
>
>cl  /I "." /I "crypto\include" /I "include" -DOPENSSL_USE_APPLINK -
>DDSO_WIN32 -DNDEBUG -DOPENSSL_THREADS -DOPENSSL_NO_STATIC_ENGINE -DOPENSSL_PIC >-DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOP
>ENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM ->DRC4_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM ->DECP_NISTZ256_ASM -DPADLOCK_ASM -DPOLY1305_ASM "-DENGIN
>ESDIR=\"C:\\Program Files\\OpenSSL\\lib\\engines-1_1\"" "->DOPENSSLDIR=\"C:\\Program Files\\Common Files\\SSL\"" -W3 -wd4090 -Gs0 -GF -Gy ->nologo -DOPENSSL_SYS_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D
>_CRT_SECURE_NO_DEPRECATE -DUNICODE -D_UNICODE /MD /O2 /Zi /Fdossl_static -c >/Focrypto\aes\aes_ige.obj "crypto\aes\aes_ige.c"
>aes_ige.c
>C:\Users\jget952\Downloads\openssl-1.1.0f\e_os.h(200): fatal error C1083: >Cannot >open include file: 'winsock2.h': No such file or directory
>NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio >14.0\VC\BIN\amd64\cl.EXE"' : return code '0x2'
>Stop.
>NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio >14.0\VC\bin\amd64\nmake.exe"' : return code '0x2'
>Stop.
>
>C:\Users\jget952\Downloads\openssl-1.1.0f>
Razorfoot
  • 397
  • 2
  • 16
  • Go through the errors please `'winsock2.h': No such file or directory`. The lib file of winsock is "ws_32.lib" (or "ws2_32.lib"), please make sure you've added it. – Gaurav Pathak Nov 03 '17 at 11:42
  • Possible duplicate of [error C1083: cannot open include file: 'winsock2.h': No such file or directory](https://stackoverflow.com/questions/21029654/error-c1083-cannot-open-include-file-winsock2-h-no-such-file-or-directory) – Gaurav Pathak Nov 03 '17 at 11:44
  • 2
    Are you using the Visual Studio Developer Command Prompt for doing this? It should set up all of your environment correctly in order to be able to find all the correct libraries and include files. There are a few variants of the command prompt. Make sure you use the 64-bit one. – Matt Caswell Nov 03 '17 at 12:01
  • @MattCaswell Maybe that should be specified in the INSTALL file then? – Enigma Nov 20 '18 at 19:15
  • @Enigma, yes it probably should (well actually really it should go in NOTES.WIN). Pull Requests for suggested improvements always welcome :-) – Matt Caswell Nov 20 '18 at 23:11

2 Answers2

11

Turns out that because I was using a normal command prompt instead of a visual studio command prompt, that nmake wasn't able to find all the libraries it needed.

Razorfoot
  • 397
  • 2
  • 16
  • Here's a useful related post: https://stackoverflow.com/questions/5879076/how-to-create-a-batch-file-for-visual-studio-command-prompt – BuvinJ May 15 '18 at 12:22
3

You have to use VC environnement. You have to find vcvarsall.bat in your visual studio installation.

With VS 2019 & VC installed :

call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64
nmake
user2226755
  • 12,494
  • 5
  • 50
  • 73