I made numerous successless attempts to build OpenSSL 1.1.0g for Android with Clang (NDK 15c Clang standalone toolchain) on Linux. The background is that Qt 5.10 needs OpenSSL 1.1.0 and Clang seems to be the recommended C++ compiler for Android (I also build Qt 5.10 with Clang).
After endless attempts my last script to build OpenSSL was this one (there are some outcommented lines from the last attempts, the script is in the OpenSSL directory):
#/bin/sh
export ANDROIDTC="${HOME}/userapps/android/clang_arm_toolchain_15"
export TCBINARIES="$ANDROIDTC/bin"
export TCINCLUDES="$ANDROIDTC/arm-linux-androideabi"
export TCSYSROOT="$ANDROIDTC/sysroot"
export STDCPPTC="$TCINCLUDES/lib/libstdc++.a"
export PATH="$PATH:$TCBINARIES:$TCINCLUDES/bin"
export AS=${TCBINARIES}/arm-linux-androideabi-clang
export CC=${TCBINARIES}/arm-linux-androideabi-clang
export CXX=${TCBINARIES}/arm-linux-androideabi-clang++
export LD=${TCBINARIES}/arm-linux-androideabi-ld
#export CFLAGS="--sysroot=$TCSYSROOT -DANDROID -Wall -I$TCSYSROOT/usr/include -I$TCSYSROOT -I$TCINCLUDES/include -O3 -fomit-frame-pointer -fPIE"
export CFLAGS="--sysroot=$TCSYSROOT -DANDROID -Wall -I$TCINCLUDES/include -O3 -fomit-frame-pointer -fPIE -std=c++14"
export CXXFLAGS="--sysroot=$TCSYSROOT -DANDROID -Wall -I$TCINCLUDES/include -O3 -fomit-frame-pointer -fPIE"
export LDFLAGS="-L$TCSYSROOT/usr/lib -L$TCINCLUDES/lib -llog -fPIE -pie"
export GDB_CFLAGS="--sysroot=$TCSYSROOT -Wall -g -I$TCINCLUDES/include"
make clean
#./config --host=arm-linux --prefix=$TCINCLUDES --libdir="$TCINCLUDES/lib"
#./Configure --host=arm-linux --prefix=$TCINCLUDES --libdir="$TCINCLUDES/lib" --disable-shared --enable-static android-armeabi
./Configure --prefix=$TCINCLUDES --libdir="$TCINCLUDES/lib" android-armeabi
#./Configure --prefix=$TCINCLUDES --libdir="$TCINCLUDES/lib" --openssldir=. android
#./config --host=x86_64-pc-linux-gnu --prefix=$TCINCLUDES --libdir="$TCINCLUDES/lib" android
#make -j 8
The output of Configure is
Configuring for android-armeabi
CC =/<HOME>/userapps/android/clang_arm_toolchain_15/bin/arm-linux-androideabi-clang
CFLAG =-Wall -O3 -pthread -fPIC --sysroot=$(CROSS_SYSROOT) -Wa,--noexecstack
SHARED_CFLAG =-fPIC -DOPENSSL_USE_NODELETE
DEFINES =DSO_DLFCN HAVE_DLFCN_H NDEBUG OPENSSL_THREADS OPENSSL_NO_STATIC_ENGINE OPENSSL_PIC OPENSSL_BN_ASM_MONT OPENSSL_BN_ASM_GF2m SHA1_ASM SHA256_ASM SHA512_ASM AES_ASM BSAES_ASM GHASH_ASM ECP_NISTZ256_ASM POLY1305_ASM
LFLAG =
PLIB_LFLAG =
EX_LIBS =-ldl
APPS_OBJ =
CPUID_OBJ =armcap.o armv4cpuid.o
UPLINK_OBJ =
BN_ASM =bn_asm.o armv4-mont.o armv4-gf2m.o
EC_ASM =ecp_nistz256.o ecp_nistz256-armv4.o
DES_ENC =des_enc.o fcrypt_b.o
AES_ENC =aes_cbc.o aes-armv4.o bsaes-armv7.o aesv8-armx.o
BF_ENC =bf_enc.o
CAST_ENC =c_enc.o
RC4_ENC =rc4_enc.o rc4_skey.o
RC5_ENC =rc5_enc.o
MD5_OBJ_ASM =
SHA1_OBJ_ASM =sha1-armv4-large.o sha256-armv4.o sha512-armv4.o
RMD160_OBJ_ASM=
CMLL_ENC =camellia.o cmll_misc.o cmll_cbc.o
MODES_OBJ =ghash-armv4.o ghashv8-armx.o
PADLOCK_OBJ =
CHACHA_ENC =chacha-armv4.o
POLY1305_OBJ =poly1305-armv4.o
BLAKE2_OBJ =
PROCESSOR =
RANLIB =ranlib
ARFLAGS =
PERL =/usr/bin/perl
THIRTY_TWO_BIT mode
BN_LLONG mode
RC4 uses unsigned char
Configured for android-armeabi.
The output of "make" is:
/usr/include/linux/errno.h:1::
In file included from /usr/include/bits/errno.h:24:
/usr/include/linux/errno.h:1:10: 10: fatal error: fatal error: 'asm/errno.h' file not found
#include <asm/errno.h>
^~~~~~~~~~~~~
'asm/errno.h' file not found
The problem in this case seems to be that the sysroot directory was not found. (Other attempts partially resulted in other errors.)
Does anybody know how to build it?
Thank you.
You need to tell Configure
where the asm
headers are for the target architecture. There are separate include directories for many architectures. It looks like you might be using a standalone toolchain, so this path might not be completely correct for you, but on my system the missing header is located at:
$ANDROID_NDK_ROOT/sysroot/usr/include/arm-linux-androideabi
You're already adding -I$TCINCLUDES/include
to your flags. All you should need to do is also add -I$TCINCLUDES/include/arm-linux-androideabi
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.