我为5/7的android-21(android-L)架构构建了openssl:armeabi,armeabi-v7a,arm64,mips,x86。但是我无法为x86_64和mips64构建它。
以下是我的x86工作脚本,使用make-standalone-toolchain创建的工具链:
export ANDROID_NDK_ROOT=/Users/jacsteve/dev/android/ndk
export ANDROID_API=android-21
export ANDROID_ARCH=arch-x86
export ANDROID_EABI=i686-linux-android-4.9
export ANDROID_SYSROOT=$ANDROID_NDK_ROOT/platforms/$ANDROID_API/arch-x86
export ANDROID_TOOLCHAIN=/tmp/toolchain/x86
export ANDROID_DEV=$ANDROID_SYSROOT/usr
export SYSTEM=android
export ARCH=x86
export CROSS_COMPILE=i686-linux-android-
export CFLAGS="--sysroot=$ANDROID_SYSROOT"
export CPPFLAGS="--sysroot=$ANDROID_SYSROOT"
export CXXFLAGS="--sysroot=$ANDROID_SYSROOT"
./Configure android-x86 shared no-asm -no-ssl2 -no-ssl3 -no-comp -no-hw --cross-compile-prefix=$CROSS_COMPILE --openssldir=/tmp/ssl/x86
make depend
make
make install
这很好用,libssl.so
libcrypto.so
和/tmp/ssl/x86
然而,x86_64失败了。这是脚本:
export ANDROID_NDK_ROOT=/Users/jacsteve/dev/android/ndk
export ANDROID_API=android-21
export ANDROID_ARCH=arch-x86_64
export ANDROID_EABI=x86_64-linux-android-4.9
export ANDROID_SYSROOT=$ANDROID_NDK_ROOT/platforms/$ANDROID_API/arch-x86_64
export ANDROID_TOOLCHAIN=/tmp/toolchain/x86_64
export ANDROID_DEV=$ANDROID_SYSROOT/usr
export SYSTEM=android
export ARCH=x86_64
export CROSS_COMPILE=x86_64-linux-android-
export CFLAGS="--sysroot=$ANDROID_SYSROOT"
export CPPFLAGS="--sysroot=$ANDROID_SYSROOT"
export CXXFLAGS="--sysroot=$ANDROID_SYSROOT"
./Configure android-x86 shared no-asm -m64 -no-ssl2 -no-ssl3 -no-comp -no-hw --cross-compile-prefix=$CROSS_COMPILE --openssldir=/tmp/ssl/x86_64
make depend
make
make install
我收到来自make
调用的大量错误消息,如下所示:
/private/tmp/toolchain/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld:
error: libcrypto.a(cryptlib.o): incompatible target
/private/tmp/toolchain/x86_64/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/bin/ld:
error: libcrypto.a(mem.o): incompatible target
...
collect2: error: ld returned 1 exit status
我认为x86_64-linux-android-gcc
正在编译所有内容,但是当我们进入链接阶段时,x86_64-linux-android-ld
无法读取已编译的目标文件。
对mips64使用类似的设置(使用./Configure android-mips ...
)我收到以下错误,这与mips64-linux-android-ld
无法读取目标文件的问题类似:
/Users/jacsteve/dev/android/ndk/platforms/android-21/arch-mips64/usr/lib/libdl.so: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
有谁知道如何成功构建x86_64和mips64架构?
答案 0 :(得分:3)
解决!
而不是
./Configure android-x86 ...
我用过
./Configure linux-generic64 ...
我还将linux-generic32
用于32位架构。
答案 1 :(得分:1)
在./Configure之前运行make clean
为我解决了问题。
答案 2 :(得分:0)
我认为构建openssl for mips64的错误是由于对象和库之间的ABI格式不兼容,格式对象是mips-ELF64,而ANDROID_NDK提供的库是mips ELF32
cd ${ANDROID_NDK_HOME}/platforms/android-24/arch-mips64/usr/lib
readelf -h libc.so
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: DYN (Shared object file)
Machine: MIPS R3000
Version: 0x1
Entry point address: 0xa7d0
Start of program headers: 52 (bytes into file)
Start of section headers: 204792 (bytes into file)
Flags: 0x50001007, noreorder, pic, cpic, o32, mips32
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 6
Size of section headers: 40 (bytes)
Number of section headers: 18
Section header string table index: 15