在 Eclipse 中设置环境变量以与 Android NDK 一起使用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8925485/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Setting environment variables in Eclipse to use with Android NDK
提问by Igor Filippov
I use Android NDK with cygwin with Eclipse on Windows. In my makefile I want to set path of prebuild library using environment variable in eclipse. So I do the following:
我在 Windows 上将 Android NDK 与 cygwin 与 Eclipse 一起使用。在我的 makefile 中,我想在 eclipse 中使用环境变量设置预构建库的路径。所以我执行以下操作:
And in makefile:
在makefile中:
LOCAL_SRC_FILES = $(QCAR_SDK_ROOT)build/lib/$(TARGET_ARCH_ABI)/libQCAR.so
LOCAL_EXPORT_C_INCLUDES := $(QCAR_SDK_ROOT)build/include
But I get error:
但我得到错误:
Android NDK: ERROR:jni/Android.mk:QCAR-prebuilt: LOCAL_SRC_FILES points to a missing file
/cygdrive/d/Development/Android/android-ndk-r7/build/core/prebuilt-library.mk:43: *** Android NDK: Aborting . Stop.
make: *** [all] Error 2
Android NDK: Check that jni//cygdrive/D/Development/Android/qcar-android-1-5-4-beta1/build/lib/armeabi/libQCAR.so exists or that its path is correct
Tried defining variable in makefile directly, got the same result.
尝试直接在 makefile 中定义变量,得到相同的结果。
So, obviously, that path is not what I wanted. How do I set the proper path?
所以,很明显,这条路不是我想要的。如何设置正确的路径?
回答by Rene
Why not just specify the paths in the make file? (N.B Just noticed you tried that.)
为什么不只在 make 文件中指定路径?(注意刚刚注意到你试过了。)
This site seems to indicate that the make file won't run correctly within Eclipse and you should run in via Windows Explorer. Are you running this within Eclipse? Try this and see if you still get the issues.
该站点似乎表明 make 文件无法在 Eclipse 中正确运行,您应该通过 Windows 资源管理器运行。你是在 Eclipse 中运行这个吗?试试这个,看看你是否仍然遇到问题。
回答by eozgonul
That's a problem of the previous NDK builds that Google fixed with NDK-9. "Updated ndk-build to support absolute paths in LOCAL_SRC_FILES."
这是 Google 使用 NDK-9 修复的先前 NDK 构建的问题。“更新了 ndk-build 以支持 LOCAL_SRC_FILES 中的绝对路径。”
See the release notes here:http://developer.android.com/tools/sdk/ndk/index.html
请参阅此处的发行说明:http: //developer.android.com/tools/sdk/ndk/index.html
回答by Alex Cohn
Recent NDK releases on Windows do not need cygwin. Worse, they do not recognize the cygdrive notation. You can simply use
Windows 上的最新 NDK 版本不需要 cygwin。更糟糕的是,它们无法识别 cygdrive 符号。你可以简单地使用
QCAR_SDK_ROOT = D:/Development/Android/qcar-android-1-5-4-beta1
correctionabsolute paths for LOCAL_SRC_FILES do not work for ndk.r7, and even for r9 the ANDROID-MK.doc does not encourage using absolute paths there.
更正LOCAL_SRC_FILES 的绝对路径对 ndk.r7 不起作用,即使对于 r9,ANDROID-MK.doc 也不鼓励在那里使用绝对路径。
回答by Eldar Abusalimov
Try to play with LOCAL_PATH
variable. As documentation (docs/ANDROID-MK.html
in Android NDK package, or here) states:
尝试使用LOCAL_PATH
变量。正如文档(docs/ANDROID-MK.html
在 Android NDK 包中或此处)所述:
LOCAL_SRC_FILES
This is a list of source files that will be built for your module. Only list the files that will be passed to a compiler, since the build system automatically computes dependencies for you.
Note that source files names are all relative to
LOCAL_PATH
and you can use path components
LOCAL_SRC_FILES
这是将为您的模块构建的源文件列表。只列出将传递给编译器的文件,因为构建系统会自动为您计算依赖项。
请注意,源文件名称都是相对的
LOCAL_PATH
,您可以使用路径组件
Also, NDK hints you to Check that jni//cygdrive/D/Development/Android/qcar-android-1-5-4-beta1/build/lib/armeabi/libQCAR.so exists or that its path is correct
.
此外,NDK 提示您使用Check that jni//cygdrive/D/Development/Android/qcar-android-1-5-4-beta1/build/lib/armeabi/libQCAR.so exists or that its path is correct
.
Thus, I would try the following:
因此,我会尝试以下操作:
LOCAL_PATH := /
...or to reset it at all:
...或者完全重置它:
LOCAL_PATH :=
回答by German Attanasio
You can edit eclipse.ini
file and add it there.
您可以编辑eclipse.ini
文件并将其添加到那里。
e.g. -DLOCAL_SRC_FILES=/home/user/.../
例如 -DLOCAL_SRC_FILES=/home/user/.../
Or declare a path variable. It is a convenient way of sharing a common location among multiple projects within a workspace.
或者声明一个路径变量。这是在工作空间内的多个项目之间共享公共位置的便捷方式。
Hope that help you!
希望能帮到你!