Including pre-created static library in Android build system

I need to create a shared library based on a previously created static library. My makefile src / android / external / mycode / Android.mk file:

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm
LOCAL_MODULE := libMyStatic
LOCAL_SRC_FILES := libStatic.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := eng
LOCAL_ARM_MODE := arm
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE    := libMyShared
LOCAL_WHOLE_STATIC_LIBRARIES := libMyStatic
include $(BUILD_SHARED_LIBRARY)

I will build it by doing: mmm external/mycode and get the error:

make: *** No rule to make target `out/target/product/generic/obj/STATIC_LIBRARIES/libMyStatic_intermediates/libMyStatic.a', needed by `out/target/product/generic/obj/SHARED_LIBRARIES/libMyShared_intermediates/LINKED/libMyShared.so'.  Stop.
make: Leaving directory `/home/test/src/android'

If I do the following manually and run mmm, it will work:

cp external/mycode/libStatic.a out/target/product/generic/obj/STATIC_LIBRARIES/libMyStatic_intermediates/libMyStatic.a

If I create an NDK project and use this Android.mk file, I think that it works right away when calling the ndk-build script. Thus, the problem is that the libMyStatic.a file is not created and is not copied to the staging folder when I use the Android Build system. Can someone tell me what I need to configure for the build system to copy the static library to an intermediate folder?

+5
2

mk

"LOCAL_WHOLE_STATIC_LIBRARIES := libMyStatic"

to

"LOCAL_LDFLAGS += -lMyStatic
+4

.

include $(CLEAR_VARS)

LOCAL_MODULE := libMyStatic
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
LOCAL_MODULE_SUFFIX := .a
LOCAL_SRC_FILES := libMyStatic.a

include $(BUILD_PREBUILT)
+1

All Articles