Reputation: 180
I have a small c++ library that must be compiled for both armeabi and armeabi7a. I also have a very large c++ library that only needs to be compiled for armeabi. Right now they are being compiled (using NDK) for both architectures, but this is making my .apk very big. Is it possible to target the big library to be compiled only for armeabi? How would I do this?
My folder structure is something like this:
/jni/biglib/
/jni/smalllib/
/jni/Application.mk
/jni/Android.mk
My /jni/Application.mk file contains:
APP_ABI := armeabi-v7a armeabi
APP_OPTIM := release
My root /jni/Android.mk file combines the Android.mk files for each library:
LOCAL_PATH := $(call my-dir)
LOCAL_C_INCLUDE := $(LOCAL_PATH)/include
include $(addprefix $(LOCAL_PATH)/, $(addsuffix /Android.mk, \
biglib \
smalllib \
))
Upvotes: 2
Views: 2272
Reputation: 146
It is definitely possible. There are some code snippets to get you going (without exact content of Android.mk for biglib and smallib I can't help you more).
1) Change order of APP_ABI
to APP_ABI := armeabi armeabi-v7a
in Application.mk
.
2) Modify your root Android.mk
:
LOCAL_PATH := $(call my-dir)
LOCAL_C_INCLUDE := $(LOCAL_PATH)/include
# biglib is not built for armeabi-v7a
ifneq "$(TARGET_ARCH_ABI)" "armeabi-v7a"
include $(LOCAL_PATH)/biglib/Android.mk
endif
# ----- cut here -----
# Place this snippet to every module which needs biglib, or where convenient.
# Now you will link against armeabi version of biglib.
ifeq "$(TARGET_ARCH_ABI)" "armeabi-v7a"
LOCAL_LDFLAGS += $(LOCAL_PATH)/../obj/local/armeabi/libbigLib.so
endif
# ----- cut here -----
include $(LOCAL_PATH)/smalllib/Android.mk
And thats all - your apk
file now doesn't contain libbiglib.so
for armeabi-v7a
Upvotes: 4