Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile OpenSSL on Windows?

I have been following the instructions in the OpenSSL User Guide, which links to a guide by 3noch for compiling OpenSSL. Here are the tools/versions I am using:

  • ActiveState Perl v5.20.2
  • Microsoft Visual Studio 2012
  • Netwide Assembler (NASM) v2.12.02
  • OpenSSL 1.0.2j (source tarball)

Following the instructions, I am able to execute the following commands without issue:

perl Configure VC-WIN32 --prefix=C:\Build-OpenSSL-VC-32
ms\do_ms

Then, when I go on to execute

nmake -f ms\nt.mak

I receive the following

 Assembling: tmp32\sha1-586.asm
tmp32\sha1-586.asm(1432) : error A2070:invalid instruction operands
tmp32\sha1-586.asm(1576) : error A2070:invalid instruction operands
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 11.0
\VC\BIN\ml.EXE"' : return code '0x1'
Stop.

After looking into that issue, I found a blog post by HostageBrain that mentions that exact error, stating to use nasm to perform the compiling. So, I switched to this command sequence:

perl Configure VC-WIN32 --prefix=C:\Build-OpenSSL-VC-32
ms\do_nasm
nmake -f ms\nt.mak

However, once switching to the NASM variation, I receive the following errors:

tmp32\sha1-586.asm:1: error: parser: instruction expected
tmp32\sha1-586.asm:2: error: parser: instruction expected
tmp32\sha1-586.asm:3: error: parser: instruction expected
tmp32\sha1-586.asm:4: warning: label alone on a line without a colon might be in error
tmp32\sha1-586.asm:5: warning: label alone on a line without a colon might be in error
tmp32\sha1-586.asm:6: warning: label alone on a line without a colon might be in error
tmp32\sha1-586.asm:7: error: symbol `IF' redefined
tmp32\sha1-586.asm:7: error: parser: instruction expected
tmp32\sha1-586.asm:8: error: parser: instruction expected
tmp32\sha1-586.asm:9: error: comma expected after operand 1

What I am looking for is to be able to compile OpenSSL into .lib files that I can then link to from other C++ projects, such as when compiling FreeTDS.

like image 833
Alex Avatar asked Oct 12 '16 20:10

Alex


People also ask

How do I compile OpenSSL source code?

Compiling OpenSSL for Linux on Ubuntu 20.04 In addition to the more advanced . configure script provided with the source, OpenSSL's source directory includes a friendlier . config script with common defaults. Make this script executable and run it.

Can you run OpenSSL on Windows?

OpenSSL for Windows has now been installed and can be found as OpenSSL.exe in C:\OpenSSL-Win32\bin\. Always open the program as Administrator.


1 Answers

On the same my blog page which you refer I also describe 'no-asm' case - this case is simpler for compiling (it won't require nasm at all), but drawback is - some algorithms performance will be 2x-4x slower than assembler versions. If your case can accept this performance - try to compile 'no-asm' case.

perl Configure VC-WIN32 no-asm --prefix=C:\Build-OpenSSL-VC-32
like image 127
HostageBrain Avatar answered Oct 09 '22 14:10

HostageBrain