在 win64 上构建 openssl 失败

build openssl on win64 fail

当 运行 此命令与 msysopenssl 源代码目录中时。

$ ./config
Operating system: x86_64-whatever-mingw
Configuring for mingw
Configuring for mingw
    no-ec_nistp_64_gcc_128 [default]  OPENSSL_NO_EC_NISTP_64_GCC_128 (skip dir)
    no-gmp          [default]  OPENSSL_NO_GMP (skip dir)
    no-jpake        [experimental] OPENSSL_NO_JPAKE (skip dir)
    no-krb5         [krb5-flavor not specified] OPENSSL_NO_KRB5
    no-libunbound   [experimental] OPENSSL_NO_LIBUNBOUND (skip dir)
    no-md2          [default]  OPENSSL_NO_MD2 (skip dir)
    no-rc5          [default]  OPENSSL_NO_RC5 (skip dir)
    no-rfc3779      [default]  OPENSSL_NO_RFC3779 (skip dir)
    no-sctp         [default]  OPENSSL_NO_SCTP (skip dir)
    no-shared       [default]
    no-ssl-trace    [default]  OPENSSL_NO_SSL_TRACE (skip dir)
    no-ssl2         [default]  OPENSSL_NO_SSL2 (skip dir)
    no-store        [experimental] OPENSSL_NO_STORE (skip dir)
    no-unit-test    [default]  OPENSSL_NO_UNIT_TEST (skip dir)
    no-weak-ssl-ciphers [default]  OPENSSL_NO_WEAK_SSL_CIPHERS (skip dir)
    no-zlib         [default]
    no-zlib-dynamic [default]
IsMK1MF=0
CC            =gcc
CFLAG         =-DOPENSSL_THREADS -D_MT -DDSO_WIN32 -DL_ENDIAN -DWIN32_LEAN_AND_M                                                                                                                                                                                               EAN -fomit-frame-pointer -O3 -march=i486 -Wall -DOPENSSL_BN_ASM_PART_WORDS -DOPE                                                                                                                                                                                               NSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM                                                                                                                                                                                                -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPO                                                                                                                                                                                               OL_ASM -DGHASH_ASM
EX_LIBS       =-lws2_32 -lgdi32 -lcrypt32
CPUID_OBJ     =x86cpuid.o
BN_ASM        =bn-586.o co-586.o x86-mont.o x86-gf2m.o
EC_ASM        =
DES_ENC       =des-586.o crypt586.o
AES_ENC       =aes-586.o vpaes-x86.o aesni-x86.o
BF_ENC        =bf-586.o
CAST_ENC      =cast-586.o
RC4_ENC       =rc4-586.o
RC5_ENC       =rc5-586.o
MD5_OBJ_ASM   =md5-586.o
SHA1_OBJ_ASM  =sha1-586.o sha256-586.o sha512-586.o
RMD160_OBJ_ASM=rmd-586.o
CMLL_ENC      =cmll-x86.o
MODES_OBJ     =ghash-x86.o
ENGINES_OBJ   =
PROCESSOR     =
RANLIB        =/c/Program Files (x86)/mingw-w64/i686-6.3.0-posix-dwarf-rt_v5-rev                                                                                                                                                                                               1/mingw32/bin/ranlib.exe
ARFLAGS       =
PERL          =/usr/bin/perl.exe
THIRTY_TWO_BIT mode
DES_PTR used
DES_RISC1 used
DES_UNROLL used
BN_LLONG mode
RC4_INDEX mode
RC4_CHUNK is undefined
e_os2.h => include/openssl/e_os2.h
/usr/bin/sh: -c: line 0: syntax error near unexpected token `('
/usr/bin/sh: -c: line 0: `set -e; target=links; for dir in crypto ssl engines ap                                                                                                                                                                                               ps test tools; do if [ -d "$dir" ]; then (      cd $dir && echo "making $target                                                                                                                                                                                                in $dir..." && TOP= && unset TOP ${LIB+LIB} ${LIBS+LIBS} ${INCLUDE+INCLUDE} ${IN                                                                                                                                                                                               CLUDES+INCLUDES} ${DIR+DIR} ${DIRS+DIRS} ${SRC+SRC} ${LIBSRC+LIBSRC} ${LIBOBJ+LI                                                                                                                                                                                               BOBJ} ${ALL+ALL} ${EXHEADER+EXHEADER} ${HEADER+HEADER} ${GENERAL+GENERAL} ${CFLA                                                                                                                                                                                               GS+CFLAGS} ${ASFLAGS+ASFLAGS} ${AFLAGS+AFLAGS} ${LDCMD+LDCMD} ${LDFLAGS+LDFLAGS}                                                                                                                                                                                                ${SCRIPTS+SCRIPTS} ${SHAREDCMD+SHAREDCMD} ${SHAREDFLAGS+SHAREDFLAGS} ${SHARED_L                                                                                                                                                                                               IB+SHARED_LIB} ${LIBEXTRAS+LIBEXTRAS} ${APPS+APPS} && C:/Program Files (x86)/min                                                                                                                                                                                               gw-w64/i686-6.3.0-posix-dwarf-rt_v5-rev1/mingw32/bin/make -e LC_ALL=C PLATFORM='                                                                                                                                                                                               mingw' PROCESSOR='' CC='gcc' CFLAG='-DOPENSSL_THREADS -D_MT -DDSO_WIN32 -DL_ENDI                                                                                                                                                                                               AN -DWIN32_LEAN_AND_MEAN -fomit-frame-pointer -O3 -march=i486 -Wall -DOPENSSL_BN                                                                                                                                                                                               _ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m                                                                                                                                                                                                -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM                                                                                                                                                                                                -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM' AS='gcc' ASFLAG='-DOPENSSL_THREADS -D_M                                                                                                                                                                                               T -DDSO_WIN32 -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -fomit-frame-pointer -O3 -march=i                                                                                                                                                                                               486 -Wall -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT                                                                                                                                                                                                -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -                                                                                                                                                                                               DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -c' AR='ar  r' NM=                                                                                                                                                                                               'nm' RANLIB='/c/Program Files (x86)/mingw-w64/i686-6.3.0-posix-dwarf-rt_v5-rev1/                                                                                                                                                                                               mingw32/bin/ranlib.exe' RC='windres' CROSS_COMPILE='' PERL='C:/Program Files/Git                                                                                                                                                                                               /usr/bin/perl.exe' ENGDIRS='ccgost' SDIRS='objects md4 md5 sha mdc2 hmac ripemd                                                                                                                                                                                                whrlpool des aes rc2 rc4 idea bf cast camellia seed modes bn ec rsa dsa ecdsa dh                                                                                                                                                                                                ecdh dso engine buffer bio stack lhash rand err evp asn1 pem x509 x509v3 conf t                                                                                                                                                                                               xt_db pkcs7 pkcs12 comp ocsp ui krb5 cms pqueue ts srp cmac' LIBRPATH='/usr/loca                                                                                                                                                                                               l/ssl/lib' INSTALL_PREFIX='' INSTALLTOP='/usr/local/ssl' OPENSSLDIR='/usr/local/                                                                                                                                                                                               ssl' LIBDIR='lib' MAKEDEPEND='$${TOP}/util/domd $${TOP} -MD gcc' DEPFLAG='-DOPEN                                                                                                                                                                                               SSL_NO_DEPRECATED -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO                                                                                                                                                                                               _JPAKE -DOPENSSL_NO_LIBUNBOUND -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RF                                                                                                                                                                                               C3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_SSL2 -DOPENSSL_NO_ST                                                                                                                                                                                               ORE -DOPENSSL_NO_UNIT_TEST -DOPENSSL_NO_WEAK_SSL_CIPHERS' MAKEDEPPROG='gcc' SHAR                                                                                                                                                                                               ED_LDFLAGS='' KRB5_INCLUDES='' LIBKRB5='' ZLIB_INCLUDE='' LIBZLIB='' EXE_EXT='.e                                                                                                                                                                                               xe' SHARED_LIBS='' SHLIB_EXT='.dll.a' SHLIB_TARGET='cygwin-shared' PEX_LIBS='' E                                                                                                                                                                                               X_LIBS='-lws2_32 -lgdi32 -lcrypt32' CPUID_OBJ='x86cpuid.o' BN_ASM='bn-586.o co-5                                                                                                                                                                                               86.o x86-mont.o x86-gf2m.o' EC_ASM='' DES_ENC='des-586.o crypt586.o' AES_ENC='ae                                                                                                                                                                                               s-586.o vpaes-x86.o aesni-x86.o' CMLL_ENC='cmll-x86.o' BF_ENC='bf-586.o' CAST_EN                                                                                                                                                                                               C='cast-586.o' RC4_ENC='rc4-586.o' RC5_ENC='rc5-586.o' SHA1_ASM_OBJ='sha1-586.o                                                                                                                                                                                                sha256-586.o sha512-586.o' MD5_ASM_OBJ='md5-586.o' RMD160_ASM_OBJ='rmd-586.o' WP                                                                                                                                                                                               _ASM_OBJ='wp_block.o wp-mmx.o' MODES_ASM_OBJ='ghash-x86.o' ENGINES_ASM_OBJ='' PE                                                                                                                                                                                               RLASM_SCHEME='coff' FIPSLIBDIR='' FIPSDIR='/usr/local/ssl/fips-2.0' FIPSCANLIB="                                                                                                                                                                                               ${FIPSCANLIB:-}" THIS=${THIS:-links} MAKEFILE=Makefile MAKEOVERRIDES= TOP=.. DIR                                                                                                                                                                                               =$dir $target ) || exit 1; fi; done'
Makefile:438: recipe for target 'links' failed
make: *** [links] Error 1

我正在使用 win64 工作站,我尝试了 INSTALL.WIN64

中的指南
You will need Microsoft Platform SDK, available for download at
 http://www.microsoft.com/msdownload/platformsdk/sdkupdate/. As per
 April 2005 Platform SDK is equipped with Win64 compilers, as well
 as assemblers, but it might change in the future.

但是我没有 Microsoft Platform SDK,而且我不知道应该下载哪个文件,因为 link 现在被重定向了。所以我尝试了 INSTALL.WIN32 中的指南,然后我我被困在这里了。

更新: 在我将 mingw 移动到一个没有 ( 的路径后,它在另一个地方失败了。

DES_INT used
RC4_CHUNK is unsigned long long
e_os2.h => include/openssl/e_os2.h
making links in crypto...
make[1]: Entering directory 'D:/Downloads/openssl-1.0.2k/crypto'
make[1]: *** No rule to make target 'links'.  Stop.
make[1]: Leaving directory 'D:/Downloads/openssl-1.0.2k/crypto'
Makefile:438: recipe for target 'links' failed
make: *** [links] Error 1

其他部分与上块最相似。

更新:使用 Microsoft VisualStudio 构建工具后

在我使用windows原生ms构建后tool.when我遇到了

nmake -f ms\ntdll.mak 
'nmake' is not recognized as an internal or external command

我找到了解决方案 here。我再次 运行 同样的 command.It 因另一个错误而失败。

nmake -f ms\ntdll.mak 
ms\uplink.c(11) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory NMAKE : fatal error U1077: 'cl' : return code '0x2'

在我的情况下 answer almost fix it.However I'm using a different version of the .net framework,then I found the detail version number with help of this post。现在我卡在这里了。

d:\Downloads\openssl-1.0.2k>nmake -f ms\ntdll.mak

Microsoft (R) Program Maintenance Utility Version 14.00.24210.0
Copyright (C) Microsoft Corporation.  All rights reserved.

Building OpenSSL
        cl /Fotmp32dll\md4_dgst.obj  -Iinc32 -Itmp32dll /MD /Ox -DOPENSSL_THREADS  -DDSO_WIN32 -W3 -Gs0 -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_DEPRECATE -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DOPENSSL_USE_APPLINK -I. -DOPENSSL_NO_RC5 -DOPENSSL_NO_MD2 -DOPENSSL_NO_SSL2 -DOPENSSL_NO_KRB5 -DOPENSSL_NO_JPAKE -DOPENSSL_NO_WEAK_SSL_CIPHERS -DOPENSSL_NO_STATIC_ENGINE /Zi /Fdtmp32dll/lib -D_WINDLL  -DOPENSSL_BUILD_SHLIBCRYPTO -c .\crypto\md4\md4_dgst.c
md4_dgst.c
.\crypto\md4\md4_dgst.c(59): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.EXE"' : return code '0x2'
Stop.

我发现 Makefile 中的一个变量让我觉得 wired.But 不确定它是正确的更改位置。

OPENSSLDIR=/usr/local/ssl

在 Bourne shell (/usr/bin/sh) 中,括号用于创建子进程,参见例如Bash - Grouping Commands

Placing a list of commands between parentheses causes a subshell environment to be created (see Command Execution Environment), and each of the commands in list to be executed in that subshell.


在错误消息中,有一个名为

的子 Make
C:/Program Files (x86)/mingw-w64/i686-6.3.0-posix-dwarf-rt_v5-rev1/mingw32/bin/make -e LC_ALL=C PLATFORM=...

包含括号。这可以通过引用命令来解决,例如

"C:/Program Files (x86)/mingw-w64/i686-6.3.0-posix-dwarf-rt_v5-rev1/mingw32/bin/make" -e LC_ALL=C PLATFORM=...

这应该可以防止 shell 将括号解释为创建子 shell 的命令。


可能还有其他地方包含一些(x86)(...)

要在 win64 上构建 openssl,使用他们的本地 Visual C++ 2015 Build Tools.Use VS native tools command is recommended,found detail in this answer.If the vcvar32.bat doesn't work,refer this answer to modify it.The .Net version reference is here 更容易。在所有这些之后,我终于在 Win64/x64 上构建了 openssl-1.0.2k