I'm trying to configure Android.mk to cross compile native code to support different chipset namely armeabi, mips, and x86. I know I can configure Application.mk in the following way to compile the source code for different chip set:
APP_ABI := all
This will trigger Android-NDK's build script to compile the source code for all the chipsets. However, I want to dynamically tell Android.mk to look for different static library dependencies compiled with different chip set.
# Get the architecture info ARCH := ???? include $(CLEAR_VARS) LOCAL_MODULE:= mylib LOCAL_SRC_FILES:= build/lib/libxxx_$(ARCH).a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) include $(PREBUILT_STATIC_LIBRARY)
Is this possible to do? If so, can anyone advice how to do so?
Update: I tried something like this in Application.mk:
APP_ABI := armeabi armeabi-v7a mips x64
with Android.mk:
# Get the architecture info ARCH := $(APP_ABI) include $(CLEAR_VARS) LOCAL_MODULE:= mylib LOCAL_SRC_FILES:= build/lib/libxxx_$(ARCH).a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) include $(PREBUILT_STATIC_LIBRARY)
but it errors with the following:
The LOCAL_SRC_FILES for a prebuilt static library should only contain one item
which makes sense. I want to pass APP_ABI := all in Application.mk and be able to dynamically reference it. Any ideas?
Code written in C/C++ can be compiled to ARM, or x86 native code (or their 64-bit variants) using the Android Native Development Kit (NDK). The NDK uses the Clang compiler to compile C/C++.
The Android.mk file resides in a subdirectory of your project's jni/ directory, and describes your sources and shared libraries to the build system. It is really a tiny GNU makefile fragment that the build system parses once or more.
NDK_PROJECT_PATH - the location of your project NDK_APPLICATION_MK - the path of the Application.mk file APP_BUILD_SCRIPT - the path to the Android.mk file. These are needed to override the default values of the build script, which expects things to be in the jni folder.
Check TARGET_ARCH_ABI
:
ifeq($(TARGET_ARCH_ABI), armeabi-v7a) # v7a-specific stuff endif
There is TARGET_ARCH
variable that holds the value of the current ABI being built. You can use it the following way:
ifeq ($(TARGET_ARCH),x86) LOCAL_CFLAGS := $(COMMON_FLAGS_LIST) else LOCAL_CFLAGS := -mfpu=vfp -mfloat-abi=softfp $(COMMON_FLAGS_LIST) endif
If you specify APP_ABI := armeabi-v7a armeabi mips x86
or APP_ABI := all
in your Application.mk
you will get each and every separate ABI value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With