这条线是什么意思? LOCAL_EXPORT_C_INCLUDES [英] What does this line mean? LOCAL_EXPORT_C_INCLUDES

查看:124
本文介绍了这条线是什么意思? LOCAL_EXPORT_C_INCLUDES的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很简单的问题,希望得到一个很简单的答案。我一直在看很多人的android.mk文件,并注意到这一行。我的NDK文档中没有文档(至少 find。-name* .txt| xargs grepLOCAL_EXPORT_C_INCLUDES没有提供任何内容)。这是我读过的唯一的文件...走在我头上...

Very simple question, hoping for a very simple answer. I've been looking at a lot of people's android.mk files and have noticed this line. I had no documentation on it within my NDK's docs (at least find . -name "*.txt" | xargs grep "LOCAL_EXPORT_C_INCLUDES" came up with nothing). This was the only documentation I've read on it...goes way over my head...

第2部分:我是否正确地假设我将需要这一行使用另一个模块预建的共享库?感谢你们(和gals)

Part 2: Am I correct in my assumption that I will need this line to use a pre-built shared library with another module? Thanks guys (and gals)


III。导出预建库的标题:



上面的示例被称为天真的,因为在实践中,
foo-user.c中的代码将依赖在通过预构建库分发的头文件(例如foo.h)中找到的特定声明通常为

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").

换句话说, user.c将会有如下一行:

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

在构建foo-user模块时,您需要向编译器
提供头文件及其包含路径。
一个简单的处理方法是在预建模块
定义中使用导出。例如,假设文件foo.h位于
下相对于预构建模块的include目录,我们可以写:

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:

包含$(CLEAR_VARS)

`include $(CLEAR_VARS)

LOCAL_MODULE:= foo-prebuilt

LOCAL_MODULE := foo-prebuilt

LOCAL_SRC_FILES:= libfoo.so

LOCAL_SRC_FILES := libfoo.so

LOCAL_EXPORT_C_INCLUDES:= $(LOCAL_PATH)/ include

LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include

include $(PREBUILT_SHARED_LIBRARY)`

include $(PREBUILT_SHARED_LIBRARY)`

这里的LOCAL_EXPORT_C_INCLUDES定义确保
的任何模块都取决于预先构建的模块将自动将其LOCAL_C_INCLUDES
添加到预建的include目录的路径,因此
可以在其中找到头文件。

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.

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

推荐答案

以下说明 LOCAL_EXPORT _ * 变量在 ANDROID-MK.html 中r6 NDK的docs文件夹:

The following explanation for the LOCAL_EXPORT_* variables in ANDROID-MK.html in the docs folder of the r6 NDK:


LOCAL_EXPORT_CFLAGS

定义此变量来记录一组C / C ++编译器将

的标志添加到使用LOCAL_STATIC_LIBRARIES或LOCAL_SHARED_LIBRARIES使用

的任何其他模块的LOCAL_CFLAGS定义。

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.

例如,使用以下定义来考虑模块foo:

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)

另一个名为bar的模块依赖于:

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)

然后, -DFOO = 1 -DBAR = 2'将被传递给编译器,当

building bar.c

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

导出的标志位于模块的LOCAL_CFLAGS之前所以你可以

轻松地覆盖它们。它们也是传递性的:如果动物园取决于取决于foo的

'bar',那么'zoo'也将继承'foo'导出的所有标志

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'.

最后,在构建

导出它们的模块时,导出的标志不是。在上面的例子中,当构建foo / foo.c时,-DFOO = 1将不会传递给

编译器。

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

与LOCAL_EXPORT_CFLAGS相同,但仅适用于C ++标志。

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

LOCAL_EXPORT_C_INCLUDES

与LOCAL_EXPORT_CFLAGS相同,但对于C包含路径。

如果'bar.c'想要包含由模块'foo'提供的头文件

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'.

这篇关于这条线是什么意思? LOCAL_EXPORT_C_INCLUDES的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆