LOCAL_EXPORT_C_INCLUDES和LOCAL_C_INCLUDES之间的区别

时间:2014-04-16 10:00:47

标签: android android-ndk

任何人都请解释一下LOCAL_EXPORT_C_INCLUDESLOCAL_C_INCLUDESmk file之间的区别。

1 个答案:

答案 0 :(得分:11)

如果模块将路径添加到LOCAL_EXPORT_C_INCLUDES,则这些路径将添加到另一个模块的LOCAL_C_INCLUDES定义中,该模块使用LOCAL_STATIC_LIBRARIESLOCAL_SHARED_LIBRARIES

考虑我们有2个模块,例如foo和bar以及以下是树结构。

.
|-- Android.mk
|-- bar
|   |-- bar.c
|   |-- bar.h
|-- foo
    |-- foo.c
    `-- foo.h

bar使用foo作为静态库。由于bar.c需要包含foo.h,因此foo模块必须添加包含LOCAL_EXPORT_C_INCLUDES的路径。如果任何模块都没有使用bar,那么它可以添加LOCAL_C_INCLUDES的包含路径。

Android.mk将如下所示:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := foo
LOCAL_SRC_FILES := foo/foo.c
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/foo
include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := bar
LOCAL_SRC_FILES := bar/bar.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/bar
LOCAL_STATIC_LIBRARIES := foo
include $(BUILD_SHARED_LIBRARY)

请查看android-ndk示例目录中提供的示例:android-ndk-r9d/samples/module-exports