包括来自预构建库Android.mk的标题文件

including header files from prebuilt library Android.mk

本文关键字:mk 标题 文件 Android 构建 包括      更新时间:2023-10-16

我使用

将预先构建的库包括
include $(PREBUILT_SHARED_LIBRARY)

使用

包括或不包括经过验证的天气库
$(modules-get-list)

当我尝试在预构建库中包含一个标头文件时,我将找不到错误标题。以下是我的确切android.mk文件

LOCAL_PATH := $(call my-dir)
# import prebuilt-library
include $(CLEAR_VARS)
LOCAL_MODULE    := prebuilt-library
LOCAL_SRC_FILES := ../../../target/dependency/libs/$(TARGET_ARCH_ABI)/libprebuilt.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)
# building provider interface library for communication
include $(CLEAR_VARS)
LOCAL_MODULE := library-interface
LOCAL_SRC_FILES := LibraryComminicator.cpp
LOCAL_SHARED_LIBRARIES := prebuilt-library
include $(BUILD_SHARED_LIBRARY)
$(warning Existing modules: "$(modules-get-list)")
# Include the Android Maven plugin generated makefile
# Important: Must be the last import in order for Android Maven Plugins paths to work
include $(ANDROID_MAVEN_PLUGIN_MAKEFILE)

尝试 android.mk 下面:

LOCAL_PATH := $(call my-dir)
EXT_LIB_ROOT := $(LOCAL_PATH)/../../../target/dependency # or whatever
# building provider interface library for communication
include $(CLEAR_VARS)
LOCAL_MODULE := library-interface
LOCAL_SRC_FILES := LibraryComminicator.cpp
LOCAL_SHARED_LIBRARIES := prebuilt-library
include $(BUILD_SHARED_LIBRARY)
# import prebuilt-library
LOCAL_PATH := $(EXT_LIB_ROOT)
include $(CLEAR_VARS)
LOCAL_MODULE    := prebuilt-library
LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/libprebuilt.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)
$(warning Existing modules: "$(modules-get-list)")

基本规则是:xxx_include_files应该相对于"当前dir",而local_src_files相对于$(local_path),而不是"当前dir"。使用NDK,通常"当前的dir"为 $(LOCAL_PATH)/..,但这可能会改变,尤其是 android.mk 文件链接的情况下,即一个包括另一个。

您确实不需要local_path即可使用prebuilt_shared_library模块,但是我更喜欢尽可能短。