简体   繁体   English

OpenSSL编译失败,x86认为x86_64成功

[英]OpenSSL compiles failed on x86 thought was successful for x86_64

I'm trying to compile my project for x86 and x86_64 architectures on Windows. 我正在尝试在Windows上编译x86和x86_64架构的项目。 Using 64bit GCC from mingwbuilds project (4.8.1 rev 5), OpenSSL 1.0.1e compiles and links successfully, but using 32bit version of same compiler I got undefined references: 使用mingwbuilds项目中的64位GCC(4.8.1 rev 5),OpenSSL 1.0.1e成功编译和链接,但使用相同编译器的32位版本我得到了未定义的引用:

libcrypto.a(cryptlib.o):cryptlib.c:(.text+0x391): undefined reference to `OPENSSL_cpuid_setup'
libcrypto.a(mem.o):mem.c:(.text+0x859): undefined reference to `OPENSSL_cleanse'
libcrypto.a(md2_dgst.o):md2_dgst.c:(.text+0x156): undefined reference to `OPENSSL_cleanse'
libcrypto.a(md2_one.o):md2_one.c:(.text+0x59): undefined reference to `OPENSSL_cleanse'
libcrypto.a(md4_one.o):md4_one.c:(.text+0x56): undefined reference to `OPENSSL_cleanse'
libcrypto.a(md5_one.o):md5_one.c:(.text+0x56): undefined reference to `OPENSSL_cleanse'
libcrypto.a(sha_one.o):sha_one.c:(.text+0x56): more undefined references to `OPENSSL_cleanse' follow
libcrypto.a(eng_all.o):eng_all.c:(.text+0x4): undefined reference to `OPENSSL_cpuid_setup'
libcrypto.a(eng_rdrand.o):eng_rdrand.c:(.text+0x4e): undefined reference to `OPENSSL_ia32_rdrand'
libcrypto.a(eng_rdrand.o):eng_rdrand.c:(.text+0x81): undefined reference to `OPENSSL_ia32_rdrand'
c:/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.8.1/../../../../i686-w64-mingw32/bin/ld.exe: libcrypto.a(eng_rdrand.o): bad reloc address 0x4 in section `.data'
collect2.exe: error: ld returned 1 exit status 

OpenSSL is configured like this: OpenSSL配置如下:

# on x86_64:
./Configure mingw64 -fPIC -O3 --prefix=/mingw shared enable-ec_nistp_64_gcc_128 
enable-krb5 enable-md2 enable-rc5 enable-rfc3779 no-asm

# and for x86:
./Configure mingw -fPIC -O3 --prefix=/mingw shared \
enable-krb5 enable-md2 enable-rc5 enable-rfc3779 no-asm

Found it myself :) This is where exports are prevented for i386 when no assembler used. 自己发现:) 是在没有使用汇编程序时阻止i386导出的地方。 Specifically: 特别:

#if defined(OPENSSL_CPUID_OBJ) && !defined(OPENSSL_NO_ASM) && !defined(I386_ONLY)
#define OPENSSL_CPUID_SETUP
#if defined(_WIN32)
typedef unsigned __int64 IA32CAP;
#else
typedef unsigned long long IA32CAP;
#endif
void OPENSSL_cpuid_setup(void)
{ ...

So, we need an assembler for x86. 所以,我们需要一个x86的汇编程序。 I Installed NASM and the library compiles successfully. 我安装了NASM并且库成功编译。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM