문제

I'm trying to compile my project for x86 and x86_64 architectures on Windows. 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:

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:

# 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. 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. I Installed NASM and the library compiles successfully.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top