我需要基于预构建的静态库构建共享库。 我的makefile是src / android / external / mycode / Android.mk:
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)
我通过这样做来构建它:mmm external/mycode
并得到错误:
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'
如果我手动执行以下操作并再次运行mmm,则可以正常工作:
cp external/mycode/libStatic.a out/target/product/generic/obj/STATIC_LIBRARIES/libMyStatic_intermediates/libMyStatic.a
如果我创建一个NDK项目并使用这个Android.mk文件,我认为它在调用ndk-build脚本时可以正常工作。所以问题与我在使用Android Build系统时没有创建libMyStatic.a文件并将其复制到中间文件夹有关。 任何人都可以告诉我我需要设置什么来使构建系统将静态库复制到中间文件夹?
答案 0 :(得分:4)
修改您的mk文件
"LOCAL_WHOLE_STATIC_LIBRARIES := libMyStatic"
到
"LOCAL_LDFLAGS += -lMyStatic
答案 1 :(得分:2)
尝试像这样构建静态库。
include $(CLEAR_VARS)
LOCAL_MODULE := libMyStatic
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
LOCAL_MODULE_SUFFIX := .a
LOCAL_SRC_FILES := libMyStatic.a
include $(BUILD_PREBUILT)