Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build OpenSSL in VS2015: x86cpuid.asm is an empty file

I need to build OpenSSL for a project that's using VS2015, 32-bit.

The instructions I found are http://developer.covenanteyes.com/building-openssl-for-visual-studio/ and an updated/edited version reportedly using VS2015 at http://blog.box.kr/?p=953 .

In the directory where I unpacked the distribution, I first did cl to verify that I had a MS Compiler build prompt (as set up by their batch file), and perl -v to make sure I had Perl. Then,

perl Configure VC-WIN32   no-idea no-mdc2 no-rc5  --prefix=e:\some\path
ms\do_ms
nmake -f ms\nt.mak

and at this last step I get:

Building OpenSSL
    perl .\util\copy-if-different.pl ".\crypto\buildinf.h" "tmp32\buildinf.h"
Copying: ./crypto/buildinf.h to tmp32/buildinf.h
    perl .\util\copy-if-different.pl ".\crypto\opensslconf.h" "inc32\openssl\opensslconf.h"
Copying: ./crypto/opensslconf.h to inc32/openssl/opensslconf.h
    ml /nologo /Cp /coff /c /Cx /Zi /Fotmp32\x86cpuid.obj tmp32\x86cpuid.asm
Assembling: tmp32\x86cpuid.asm
tmp32\x86cpuid.asm(1) : error A2088:END directive required at end of file
NMAKE : fatal error U1077: '"D:\@Prog-Charon\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\ml.EXE"' : return code '0x1'
Stop.

I find that E:\C++Libs\openssl-1.0.2e\tmp32\x86cpuid.asm is a zero-length file.

What I really want is to have (build or find ready-made) a static library for a project that will use the dynamic run-time library.


Update: if I run the step manually,

perl crypto\x86cpuid.pl win32 > tmp32\x86cpuid.asm

then when the makefile gets to that file it gives me

    ml /nologo /Cp /coff /c /Cx /Zi /Fotmp32\x86cpuid.obj tmp32\x86cpuid.asm
Assembling: tmp32\x86cpuid.asm
tmp32\x86cpuid.asm(35) : error A2085:instruction or register not accepted in current CPU mode
tmp32\x86cpuid.asm(59) : error A2085:instruction or register not accepted in current CPU mode
tmp32\x86cpuid.asm(64) : error A2085:instruction or register not accepted in current CPU mode
tmp32\x86cpuid.asm(70) : error A2085:instruction or register not accepted in current CPU mode
tmp32\x86cpuid.asm(75) : error A2085:instruction or register not accepted in current CPU mode
tmp32\x86cpuid.asm(90) : error A2085:instruction or register not accepted in current CPU mode
tmp32\x86cpuid.asm(98) : error A2085:instruction or register not accepted in current CPU mode
tmp32\x86cpuid.asm(105) : error A2085:instruction or register not accepted in current CPU mode
tmp32\x86cpuid.asm(165) : error A2085:instruction or register not accepted in current CPU mode
tmp32\x86cpuid.asm(182) : error A2085:instruction or register not accepted in current CPU mode
tmp32\x86cpuid.asm(186) : error A2085:instruction or register not accepted in current CPU mode
tmp32\x86cpuid.asm(322) : error A2085:instruction or register not accepted in current CPU mode
tmp32\x86cpuid.asm(335) : error A2085:instruction or register not accepted in current CPU mode
NMAKE : fatal error U1077: '"D:\@Prog-Charon\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\ml.EXE"' : return code '0x1'

Now it happens that line 35 etc. is cpuid, which is the whole point of having this file!

like image 688
JDługosz Avatar asked Dec 22 '15 07:12

JDługosz


1 Answers

Building OpenSSL 1.0.2d as a static library on Windows

Note: Following text is extracted from my building instructions for SoftHSM2.

Required software

  • Visual Studio (2015 Community)
  • GNU Privacy Guard for Windows (2.2.5)
  • 7-zip (9.20)
  • Strawberry Perl (5.22.0.1)
  • The Netwide Assembler (2.11.08)

Preparations

Create working directories:

mkdir C:\build\bin\
mkdir C:\build\src\

Download OpenSSL 1.0.2d with its signature into C:\build\src\ directory and verify signature of the downloaded archive:

cd C:\build\src\
gpg --keyserver pgp.mit.edu --recv-keys 0E604491
gpg --verify openssl-1.0.2d.tar.gz.asc openssl-1.0.2d.tar.gz

Building 32-bit version

Extract archive openssl-1.0.2d.tar.gz into C:\build\src\openssl-1.0.2d-x86 directory:

cd C:\build\src\
"C:\Program Files\7-Zip\7z" x openssl-1.0.2d.tar.gz
"C:\Program Files\7-Zip\7z" x openssl-1.0.2d.tar
rename openssl-1.0.2d openssl-1.0.2d-x86
del openssl-1.0.2d.tar

In a new command line window build OpenSSL and install it into C:\build\bin\openssl-1.0.2d-x86 directory:

cd C:\build\src\openssl-1.0.2d-x86
set PATH=%PATH%;C:\nasm
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
perl Configure VC-WIN32 --prefix=C:\build\bin\openssl-1.0.2d-x86 enable-static-engine
ms\do_nasm
nmake /f ms\nt.mak
nmake /f ms\nt.mak test
nmake /f ms\nt.mak install

Resulting build is located in C:\build\bin\openssl-1.0.2d-x86 directory.

Building 64-bit version

Extract archive openssl-1.0.2d.tar.gz into C:\build\src\openssl-1.0.2d-x64 directory:

cd C:\build\src\
"C:\Program Files\7-Zip\7z" x openssl-1.0.2d.tar.gz
"C:\Program Files\7-Zip\7z" x openssl-1.0.2d.tar
rename openssl-1.0.2d openssl-1.0.2d-x64
del openssl-1.0.2d.tar

In a new command line window build OpenSSL and install it into C:\build\bin\openssl-1.0.2d-x64 directory:

cd C:\build\src\openssl-1.0.2d-x64
set PATH=%PATH%;C:\nasm
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
perl Configure VC-WIN64A --prefix=C:\build\bin\openssl-1.0.2d-x64 enable-static-engine
ms\do_win64a
nmake /f ms\nt.mak
nmake /f ms\nt.mak test
nmake /f ms\nt.mak install

Resulting build is located in C:\build\bin\openssl-1.0.2d-x64 directory.

like image 131
jariq Avatar answered Oct 21 '22 15:10

jariq