我正在尝试使用预构建的静态库构建共享库,相应的Android.mk文件位于下方。
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
#Include kerne headers in a proper way later on
#LOCAL_C_INCLUDES:= $(LOCAL_PATH)/../../../../kernel/include
LOCAL_MODULE := sensors.$(TARGET_BOARD_PLATFORM)
LOCAL_MODULE_TAGS := optional
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
LOCAL_STATIC_LIBRARIES := LibFusion_ARM_cpp
#LOCAL_LDFLAGS := $(LOCAL_PATH)/LibFusion_ARM_cpp.a
LOCAL_SHARED_LIBRARIES := liblog libcutils
#include any shared library dependencies
LOCAL_LDFLAGS := $(LOCAL_PATH)/libimu.a
LOCAL_PRELINK_MODULE := false
LOCAL_SRC_FILES := sensors_u8500.cpp
include $(BUILD_SHARED_LIBRARY)
文件夹中存在的文件是 Android.mk,LibFusion_ARM_cpp.a,libimu.a,MEMSAlgLib_eCompass.h,sensors_u8500.cpp
构建时我得到的错误是
**make: *** No rule to make target `out/target/product/u8500/obj/STATIC_LIBRARIES/LibFusion_ARM_cpp_intermediates/LibFusion_ARM_cpp.a', needed by `out/target/product/u8500/obj/SHARED_LIBRARIES/sensors.montblanc_intermediates/LINKED/sensors.montblanc.so'. Stop.**
这里有什么问题?
无法构建共享库。我的意思是无法生成libsensor.so文件。面对上述错误。 ** make: * 没有制定目标的规则
答案 0 :(得分:0)
似乎构建系统找不到LibFusion_ARM_cpp.a
。 AFAIK,您必须先使用PREBUILT_STATIC_LIBRARY
指定预先构建的库模块,LibFusion_ARM_cpp.a
设置为LOCAL_SRC_FILES
,LOCAL_MODULE
设置为LibFusion_ARM_cpp
。这将基本上将指定的静态库复制到构建系统搜索所有必需模块的默认目录。
答案 1 :(得分:0)
我做了两件事来理解这个案子:
一个。在上面显示的make文件中,我添加了以下内容,以确保将.a文件复制到构建中。
include $(CLEAR_VARS)
LOCAL_MODULE := LibFusion_ARM
LOCAL_SRC_FILES := LibFusion_ARM_cpp.a
include $(BUILD_STATIC_LIBRARY)
当我使用mm -n
构建它时,命令我看到LibFusion_ARM.a的这个奇怪的语句rm -f ...
。当然,构建失败,说它无法找到STATIC LIB
。
mkdir -p out/target/product/u8500/obj/STATIC_LIBRARIES/LibFusion_ARM_intermediates/
rm -f out/target/product/u8500/obj/STATIC_LIBRARIES/LibFusion_ARM_intermediates/LibFusion_ARM.a
echo "target StaticLib: LibFusion_ARM (out/target/product/u8500/obj/STATIC_LIBRARIES/LibFusion_ARM_intermediates/LibFusion_ARM.a)"
mkdir -p out/target/product/u8500/obj/SHARED_LIBRARIES/sensors.montblanc_intermediates/LINKED/
.
.
为什么会发生这种删除?我不确定。这导致了这个问题。请提供建议。
B中。我在make文件中添加了以下行:
include $(CLEAR_VARS)
LOCAL_MODULE := LibFusion_ARM
LOCAL_SRC_FILES := LibFusion_ARM_cpp.a
include $(PREBUILT_STATIC_LIBRARY)
我看到以下错误:
make: *** No rule to make target `out/target/product/u8500/obj/STATIC_LIBRARIES/LibFusion_ARM_intermediates/LibFusion_ARM.a', needed by `out/target/product/u8500/obj/SHARED_LIBRARIES/sensors.montblanc_intermediates/LINKED/sensors.montblanc.so'.
Stop.
显然在第二种情况下,文件LibFusion_ARM没有被复制(甚至没有创建obj/STATIC_LIBRARIES/LibFusion_ARM_intermediates
目录)。
不用强调,如果我手动将文件LibFusion_ARM_cpp.a复制为LibFusion_ARM.a,那么构建就会完成。