Android的NDK:如何让GCC使用其他包含目录 [英] Android NDK: how to let gcc to use additional include directories
问题描述
一个简单的问题(我使用的Android NDK R6与Cygwin的,但这是对于makefile和海湾合作委员会的问题)。假设我把JNI /目录下的目录mylib_v_1 /下的库。 mylib中的结构为:
A simple questions (i am using android NDK r6 with cygwin, but this is a question regarding makefiles and gcc). Suppose that i put under jni/ directory a library under the dir mylib_v_1/. Mylib is structured as:
mylib_v_1
mylib
include
下包括目录下有两个文件,myinc1.hpp和myinc2.hpp。在myinc1.hpp有一行如下:
Under the include directory there are two files, myinc1.hpp and myinc2.hpp. In myinc1.hpp there is a line as:
#include <mylib/myinc2.hpp>
在我的.cpp文件中,JNI /目录下,有以下行:
in my .cpp file, under the jni/ directory, there is the following line:
#include <mylib/myinc1.hpp>
我想设置的Android.mk(或需要设置什么其他文件),以让GCC知道使用,作为附加包括目录,JNI / mylib_v_1 /为了使用的#include括号(而不是两个文件,在我的真实案例有很多.HPP的,其中包括了很多其他的.HPP括号表示法)。
I want to setup the Android.mk (or what other files needs to be set up) in order to let gcc to know to use, as additional include directory, jni/mylib_v_1/ in order to use #include with brackets (instead of two files, in my real case there are a lot of .hpp that includes a lot of other .hpp with brackets notation).
我怎样才能做到这一点?
How can i do this?
THX。
诗。
如果在.cpp文件我改变包括以这种方式:
Ps. If, in the .cpp file i change the include in this way:
#include "mylib/myinc1.hpp"
GCC找到myinc1.hpp但是,在处理它,它找到第二个包括:
gcc find myinc1.hpp but, while processing it, it find the second include:
#include <mylib/myinc2.hpp>
和停在那里,说是无法找到文件myinc2.hpp。
and stop there, saying that it is not able to find the file myinc2.hpp.
推荐答案
选项1:
添加以下行之一的Android.mk您选择的模块中:
Add one of the following lines to your Android.mk inside a module of your choice:
LOCAL_C_INCLUDES := /path/to/your/includes # ignore previous includes
# OR
LOCAL_C_INCLUDES += /path/to/your/includes # preserve previous includes
如果有必要,您可以创建为'/路径/要/你/包括环境变量指向的,包括它是这样的:
If necessary you could create an environment variable pointing at '/path/to/your/includes' and include it like this:
LOCAL_C_INCLUDES := $(MYLIB_INCLUDES_PATH) # ignore previous includes
# OR
LOCAL_C_INCLUDES += $(MYLIB_INCLUDES_PATH) # preserve previous includes
选项2:
-
在它(MYLIB)复制所有的报头文件完整的文件夹到你项目的JNI文件夹中。
Copy the complete folder with all header-files in it (mylib) into the 'jni' folder of your project.
以下行添加到您的Android.mk您选择的模块中:
Add the following line to your Android.mk inside a module of your choice:
LOCAL_C_INCLUDES := $(LOCAL_PATH)/mylib
或
LOCAL_C_INCLUDES += $(LOCAL_PATH)/mylib
根据是否有previous包括与否。
Depending on whether there are previous includes or not.
选项3:
安装CDT的Eclipse插件和绝对路径添加到MYLIB目录到项目的包含路径。这里是一个伟大的教程,显示所有必要的步骤。
Install the CDT plugin for Eclipse and add the absolute path to the 'mylib' directory to the include paths of your project. Here is a great tutorial that shows all the necessary steps.
<一个href=\"http://mhandroid.word$p$pss.com/2011/01/23/using-eclipse-for-android-cc-development/\">http://mhandroid.word$p$pss.com/2011/01/23/using-eclipse-for-android-cc-development/
这篇关于Android的NDK:如何让GCC使用其他包含目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!