JustWonder
JustWonder

Reputation: 2433

Use Prebuilt Shared Library in Android AOSP

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?

Upvotes: 9

Views: 7893

Answers (1)

JustWonder
JustWonder

Reputation: 2433

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)

Upvotes: 10

Related Questions