Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'configure' failing with Android NDK standalone toolchain

I'm trying to build something with the Android NDK standalone compiler toolchain, but I'm getting this error:

Updating bundled third-party dependencies...

bash -c 'mkdir -p output/{debug,release,test}/{FCollada/{FCDocument,FMath,FUtils,FColladaTest/{FCTestAssetManagement,FCTestExportImport,FCTestXRef}},FColladaPlugins/FArchiveXML}'
cp output/libFColladaSD.a ../lib/libFColladaSD.a
cp output/libFColladaSR.a ../lib/libFColladaSR.a

Building SpiderMonkey...

SpiderMonkey build options: --disable-tests         
loading cache ./config.cache
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking build system type... x86_64-unknown-linux-gnu
checking for mawk... mawk
checking for perl5... no
checking for perl... /usr/bin/perl
checking for gcc... gcc
checking whether the C compiler (gcc  ) works... yes
checking whether the C compiler (gcc  ) is a cross-compiler... no
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
checking for c++... arm-linux-androideabi-g++
checking whether the C++ compiler (arm-linux-androideabi-g++  ) works... no
configure: error: installation or configuration problem: C++ compiler cannot create executables.
ERROR: SpiderMonkey build failed

This is what the config.log says: http://pastebin.com/5AFZG4CX

My ANDROID_NDK_ROOT is set as follows:

afeder@ubuntu:~/android/0ad/build/workspaces$ echo $ANDROID_NDK_ROOT
/home/afeder/android/android-ndk-r7-crystax-4

What might be the cause or how do I debug it? Thank you.

like image 739
Anders Feder Avatar asked Jan 20 '12 12:01

Anders Feder


People also ask

What is Android toolchain?

The toolchain is the set of all the tools needed to effectively compile a specific software to a binary version, enabling the user to run it. In our specific domain, the toolchain allows us to create a system image ready to be flashed to our Android device.

What is NDK Sysroot?

$NDK/sysroot is the unified headers and is what you should be using when compiling. When linking, you should still be using $NDK/platforms/android-$API/arch-$ARCH . We do have a doc explaining how to use unified headers in a custom build system: android.googlesource.com/platform/ndk/+/master/docs/….

Is NDK necessary for Android studio?

Using Android Studio 2.2 and higher, you can use the NDK to compile C and C++ code into a native library and package it into your APK using Gradle, the IDE's integrated build system. Your Java code can then call functions in your native library through the Java Native Interface (JNI) framework.


2 Answers

To me this looks broken:

checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking build system type... x86_64-unknown-linux-gnu

Here's how I'd set up the environment for my Android NDK build:

export CROSS_COMPILE=arm-linux-androideabi
export CC=${CROSS_COMPILE}-gcc
export CXX=${CROSS_COMPILE}-g++

... other binutils as needed ...

export NDK=/home/afeder/android/android-ndk-r7-crystax-4
export SYSROOT=$NDK/platforms/android-8/arch-arm
PATH=$PATH:$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin

Make sure and add --sysroot=$SYSROOT to CFLAGS, CPPFLAGS, and/or CXXFLAGS.

Now you need to tell the spidermonkey configure that you are cross compiling:

./configure --build=x86_64-unknown-linux-gnu --host=arm-linux-androideabi --target=arm-linux-androideabi
like image 89
ldav1s Avatar answered Sep 30 '22 09:09

ldav1s


It looks like it can't find arm-linux-androideabi-g++. Try searching for it in the NDK folder and adding the directory to your PATH.

Mine is here:

ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-g++
like image 25
James McLaughlin Avatar answered Sep 30 '22 08:09

James McLaughlin