android - 这条线是什么意思? LOCAL_EXPORT_C_INCLUDES

标签 android android-ndk

非常简单的问题,希望得到一个非常简单的答案。我一直在查看很多人的 android.mk 文件并注意到这一行。我的 NDK 文档中没有关于它的文档(至少 find . -name "*.txt"| xargs grep "LOCAL_EXPORT_C_INCLUDES" 什么也没找到)。这是我读过的关于它的唯一文档...超出我的理解范围...

第 2 部分:我的假设是否正确,即我需要这一行才能将预构建的共享库与另一个模块一起使用?谢谢伙计们(和姑娘们)

III. Exporting headers for prebuilt libraries:

The example above was called 'naive' because, in practice, the code in foo-user.c is going to depend on specific declarations that are normally found in a header file distributed with the prebuilt library (e.g. "foo.h").

In other words, foo-user.c is going to have a line like:

include < foo.h >

And you need to provide the header and its include path to the compiler when building the foo-user module. A simple way to deal with that is to use exports in the prebuilt module definition. For example, assuming that a file "foo.h" is located under the 'include' directory relative to the prebuilt module, we can write:

`include $(CLEAR_VARS)

LOCAL_MODULE := foo-prebuilt

LOCAL_SRC_FILES := libfoo.so

LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include

include $(PREBUILT_SHARED_LIBRARY)`

The LOCAL_EXPORT_C_INCLUDES definition here ensures that any module that depends on the prebuilt one will have its LOCAL_C_INCLUDES automatically prepended with the path to the prebuilt's include directory, and will thus be able to find headers inside that.

网址:http://www.srombauts.fr/android-ndk-r5b/docs/PREBUILTS.html

最佳答案

下面对ANDROID-MK.html中的LOCAL_EXPORT_*变量进行解释在 r6 NDK 的文档文件夹中:

LOCAL_EXPORT_CFLAGS
Define this variable to record a set of C/C++ compiler flags that will
be added to the LOCAL_CFLAGS definition of any other module that uses
this one with LOCAL_STATIC_LIBRARIES or LOCAL_SHARED_LIBRARIES.

For example, consider the module 'foo' with the following definition:

   include $(CLEAR_VARS)
   LOCAL_MODULE := foo
   LOCAL_SRC_FILES := foo/foo.c
   LOCAL_EXPORT_CFLAGS := -DFOO=1
   include $(BUILD_STATIC_LIBRARY)

And another module, named 'bar' that depends on it as:

   include $(CLEAR_VARS)
   LOCAL_MODULE := bar
   LOCAL_SRC_FILES := bar.c
   LOCAL_CFLAGS := -DBAR=2
   LOCAL_STATIC_LIBRARIES := foo
   include $(BUILD_SHARED_LIBRARY)

Then, the flags '-DFOO=1 -DBAR=2' will be passed to the compiler when
building bar.c

Exported flags are prepended to your module's LOCAL_CFLAGS so you can
easily override them. They are also transitive: if 'zoo' depends on
'bar' which depends on 'foo', then 'zoo' will also inherit all flags
exported by 'foo'.

Finally, exported flags are not used when building the module that
exports them. In the above example, -DFOO=1 would not be passed to the
compiler when building foo/foo.c.

LOCAL_EXPORT_CPPFLAGS
Same as LOCAL_EXPORT_CFLAGS, but for C++ flags only.

LOCAL_EXPORT_C_INCLUDES
Same as LOCAL_EXPORT_CFLAGS, but for C include paths.
This can be useful if 'bar.c' wants to include headers
that are provided by module 'foo'.

关于android - 这条线是什么意思? LOCAL_EXPORT_C_INCLUDES,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6595208/

相关文章:

安卓电话号码

android - 在android模拟器中安装操作系统

ios - 如何组织Android NDK/iOS项目

android - 尝试使用 NDK 构建 PocketSphinxAndroidDemo 时出现问题

C NDK ndk-build 无法识别 header 错误 : undefined reference to 'cpBBTreeNew'

android - fragment 中的条码扫描器

android - 某些文件不会从 lighttpd 流式传输到 Droid

Android 状态栏与协调器布局一起向上滚动,使状态图标与工具栏标题重叠

安卓开发: updating code to more recent NDK?

Android OpenCV VideoCapture::retrieve(&mat) 导致致命信号 11