ndk-build chooses wrong arch if run in docker container

205 views
Skip to first unread message

dicky dicky

unread,
Oct 16, 2015, 9:53:54 AM10/16/15
to android-ndk
Hi
i try to build adAway[1] in a docker-container (since i build everything in containers).
i am able to build it locally on my dev-machine, but it fails in the container.
I have this Dockerfile[2].
if i run it interactive it fails:

# ndk-build

/root/android-ndk-r10e/ndk-build: 158: /root/android-ndk-r10e/ndk-build: file: not found

/bin/sh: 1: file: not found

[armeabi] Compile thumb  : blank_webserver <= blank_webserver.c

make: /root/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc: Command not found

/root/android-ndk-r10e/build/core/build-binary.mk:464: recipe for target 'obj/local/armeabi/objs/blank_webserver/blank_webserver.o' failed

make: *** [obj/local/armeabi/objs/blank_webserver/blank_webserver.o] Error 127


to my eyes it looks like its searching the prebuild compiler for a x86 host, even its clearly a 64bit arcitecture:


# uname -m

x86_64


is it me who does something wrong or is it a bug?






Sergey Z.

unread,
Jul 11, 2017, 2:37:39 PM7/11/17
to android-ndk
 It may happen if your system is missing `file' command. To check it, run ndk-build with logging enabled:

$ NDK_LOG=1 /opt/android-ndk-r10e/ndk-build -n | grep HOST -C 5
HOST_OS=linux
HOST_ARCH=x86_64
/opt/android-ndk-r10e/ndk-build: 158: /opt/android-ndk-r10e/ndk-build: file: not found
HOST_ARCH=x86 (32-bit userland detected)
HOST_TAG=linux-x86 
GNUMAKE=/usr/bin/make (system path)
Android NDK: NDK installation path auto-detected: '/opt/android-ndk-r10e'
Android NDK: GNU Make version 4.1 detected
Android NDK: Host OS was auto-detected: linux
Android NDK:  Host operating system detected: linux

/bin/sh: 1: file: not found
Android NDK: Host CPU was auto-detected: x86
Android NDK: HOST_TAG set to linux-x86
Android NDK: Host tools prebuilt directory not found

Install `file' to fix the problem.

After installing `file' you still might see that HOST_TAG was set to linux-x86.

HOST_OS=linux
HOST_ARCH=x86_64
HOST_ARCH=x86 (32-bit userland detected)
HOST_TAG=linux-x86 
GNUMAKE=/usr/bin/make (system path)
Android NDK: NDK installation path auto-detected: '/opt/android-ndk-r10e'
Android NDK: GNU Make version 4.1 detected
Android NDK: Host OS was auto-detected: linux
Android NDK:  Host operating system detected: linux
Android NDK: Host CPU was auto-detected: x86
Android NDK: HOST_TAG set to linux-x86
Android NDK: Host tools prebuilt directory: /opt/android-ndk-r10e/prebuilt/linux-x86_64/bin
Android NDK: Host 'echo' tool: echo
Android NDK: Host 'echo -n' tool: printf %s
Android NDK: Host 'cmp' tool: cmp
Android NDK: Host 'awk' tool: /opt/android-ndk-r10e/prebuilt/linux-x86_64/bin/awk


That happens because ndk-build script runs in /bin/sh (dash) and for some reason "$SHELL" becomes empty in it. Anyhow, because 'build/core/init.mk' does correct detection, NDK still works even without correct HOST_ARCH.
Reply all
Reply to author
Forward
0 new messages