Android NDK and LOCAL_ARM_MODE flag

android, android-ndk

Solution

The LOCAL_ARM_MODE can be used to define the platform your application is targeting. To have your Android.mk setup also for x86 just include the required info to your Android.mk file - e.g.:

ifeq ($(TARGET_ARCH),arm)
    LOCAL_CFLAGS := -mfpu=neon -march=armv6t2 -O9
    LOCAL_SRC_FILES := engine-arm.s
endif
ifeq ($(TARGET_ARCH),x86)
    LOCAL_CFLAGS := -msse2 -m32 -masm=intel
    LOCAL_SRC_FILES := engine-x86.s
endif

For more info about different option on defining your application target, have a look in /docs/Android-mk.

Source: Compile assembly code for ARM and X86

Problem

In my current Android native code build setup, APP_ABI is defined to armeabi-v7a in Application.mk. For some of the libraries that I am building, I see that LOCAL_ARM_MODE is defined as arm in Android.mk. I need to extend this setup to build for x86 as well. From another post, it appears using "APP_ABI = all" is a better solution. I am just wondering if LOCAL_ARM_MODE must be changed as well. What does this flag do anyway?

Original source