0

我正在尝试使用预构建的静态库构建共享库,相应的 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: *没有制定目标的规则

4

2 回答 2

0

我做了两件事来理解这个案子:

A. 在上面显示的 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,那么构建就会通过。

于 2012-06-28T12:34:21.307 回答
0

似乎构建系统找不到LibFusion_ARM_cpp.a. PREBUILT_STATIC_LIBRARYAFAIK,您必须首先使用with LibFusion_ARM_cpp.aset asLOCAL_SRC_FILESLOCAL_MODULEas指定一个预构建的库模块LibFusion_ARM_cpp。这基本上会将指定的静态库复制到构建系统搜索所有必要模块的默认目录。

于 2012-06-21T21:44:32.357 回答