I want to use a pre-built shared library in AOSP. The library is defined in Android.mk like this:
include $(CLEAR_VARS)
LOCAL_MODULE := foo
LOCAL_MODULE_SUFFIX := .so
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_TAG := optional
LOCAL_MODULE_PATH := system/lib
LOCAL_SRC_FILE := system/lib/foo.so
include $(BUILD_PREBUILT)
During build, a folder out/target/product/mako/obj/SHARED_LIBRARIES/foo_intermediates/export_include
was created.
However, the build failed with error message that out/target/product/mako/obj_arm/SHARED_LIBRARIES/foo_intermediates/export_include
cannot be found.
Note the difference between "obj" and "obj_arm". What caused the problem?
2.1. Similar to the traditional Linux model, shared libraries in Android are relocatable ELF files that map to the address space of the process when loaded. To save memory and avoid code duplication, all shared objects shipped with Android are dynamically linked against the Bionic libc library [23].
system/vendor/lib.
This is two-target build (arm and arm64), so there are two obj folders, one for 32-bit arm and the other for 64-bit arm.
I need to define the library as follows:
include $(CLEAR_VARS)
LOCAL_MODULE := libfoo
LOCAL_MODULE_SUFFIX :=.so
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_TAGS := optional
LOCAL_PRELINK_MODULE := false
ifdef TARGET_2ND_ARCH
LOCAL_MULTILIB := both
LOCAL_MODULE_PATH_64 := system/lib64
LOCAL_SRC_FILES_64 := system/lib64/libfoo.so
LOCAL_MODULE_PATH_32 := system/lib
LOCAL_SRC_FILES_32 := system/lib/libfoo.so
else
LOCAL_MODULE_PATH := system/lib
LOCAL_SRC_FILES := system/lib/libfoo.so
endif
include $(BUILD_PREBUILT)
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