Android – cross compile: error adding symbols: File in wrong format

android, arm64, cross-compiling

I'm trying to cross compile fdk-aac for arm-v8.

here is my build script:

#!/bin/shNDK_HOME=/home/ubuntu/android-ndk-r12bINSTALL_DIR=/home/ubuntu/compiledSYSROOT=$NDK_HOME/platforms/android-16/arch-arm/TOOLCHAIN=$NDK_HOME/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64CROSS_PREFIX=$TOOLCHAIN/bin/aarch64-linux-android-CC={$CROSS_PREFIX}gccCXX={$CROSS_PREFIX}g++CPP={$CROSS_PREFIX}cppCXXCPP={$CROSS_PREFIX}cpp./configure \--prefix=$INSTALL_DIR \--with-sysroot=$SYSROOT \--host=aarch64 \--enable-shared \--with-pic=no \CC="${CROSS_PREFIX}gcc --sysroot=$SYSROOT" \CXX="${CROSS_PREFIX}g++ --sysroot=$SYSROOT" \RANLIB="${CROSS_PREFIX}ranlib" \AR="${CROSS_PREFIX}ar" \STRIP="${CROSS_PREFIX}strip" \NM="${CROSS_PREFIX}nm" \LD="${CROSS_PREFIX}ld --sysroot=$SYSROOT" \CFLAGS="-O2 $OPTIMIZE_CFLAGS --sysroot=$SYSROOT" \CXXFLAGS="-O2 $OPTIMIZE_CFLAGS --sysroot=$SYSROOT"#make#make install

make and make install are useless, because ./configure failed and the error message ask me to check the config.log:

configure:3243: checking whether the C compiler worksconfigure:3265: /home/ubuntu/android-ndk-r12b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-gcc --sysroot=/home/ubuntu/android-ndk-r12b/platforms/android-16/arch-arm/ -O2  --sysroot=/home/ubuntu/android-ndk-r12b/platforms/android-16/arch-arm/   conftest.c >&5/home/ubuntu/android-ndk-r12b/platforms/android-16/arch-arm/usr/lib/crtbegin_dynamic.o: error adding symbols: File in wrong formatcollect2: error: ld returned 1 exit statusconfigure:3269: $? = 1configure:3307: result: noconfigure: failed program was:| /* confdefs.h */| #define PACKAGE_NAME "fdk-aac"| #define PACKAGE_TARNAME "fdk-aac"| #define PACKAGE_VERSION "0.1.4"| #define PACKAGE_STRING "fdk-aac 0.1.4"| #define PACKAGE_BUGREPORT "http://sourceforge.net/projects/opencore-amr/"| #define PACKAGE_URL ""| #define PACKAGE "fdk-aac"| #define VERSION "0.1.4"| /* end confdefs.h.  */| | int| main ()| {| |   ;|   return 0;| }configure:3312: error: in `/home/ubuntu/fdk-aac-0.1.4':configure:3314: error: C compiler cannot create executables

I don't know which config is wrong about the build script. This is my first time to cross compile library for ARM64…

Best Solution

I have add these two statements "SET(CMAKE_C_COMPILER "mips-linux-uclibc-gnu-gcc") SET(CMAKE_CXX_COMPILER "mips-linux-uclibc-gnu-g++") " and build success, maybe help you.