eclipse 使用 NDK 时未解决的包含错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7798960/
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
Unresolved inclusion error while using NDK
提问by Waneya Iqbal
I am using Android NDK but the .c file in the JNI folder is showing the error of Unresolved inclusion as shown in the image: Kindly help me in solving this issue. I have tried almost everything I could find on internet but unable to solve it. For a C/C++ project I can use the build path\paths and symbols option to solve the inclusion but for an android project, this option is not available in project properties.
我正在使用 Android NDK,但 JNI 文件夹中的 .c 文件显示未解决的包含错误,如图所示:请帮助我解决此问题。我已经尝试了几乎所有我可以在互联网上找到的东西,但无法解决它。对于 C/C++ 项目,我可以使用构建路径\路径和符号选项来解决包含问题,但对于 android 项目,此选项在项目属性中不可用。
回答by Andrew
This is a bug in the ADT plugin (or rather, it sounds like an incompatibility with the newer version of CDT for Eclipse) on Windows documented here: http://code.google.com/p/android/issues/detail?id=33788
这是 Windows 上的 ADT 插件中的一个错误(或者更确切地说,它听起来像是与更新版本的 Eclipse CDT 不兼容),记录在此处:http: //code.google.com/p/android/issues/detail?id =33788
There's a preview of a new version which fixes the problem described here: http://tools.android.com/download/adt-21-preview#TOC-Installation
有一个新版本的预览,它修复了这里描述的问题:http: //tools.android.com/download/adt-21-preview#TOC-Installation
Here's what I needed to do to fix the problem:
这是我需要做的来解决这个问题:
- Enable Preview Tools in the Options of the SDK Manager, then install the preview version of the SDK tools.
- Install the preview version of ADT and NDK plugins in Eclipse using the link in the preview description linked above.
- Re-create my project so that I could re-do the "Add Native Support" step (apparently required for the fix to work).
- 在 SDK Manager 的 Options 中启用 Preview Tools,然后安装 SDK 工具的预览版。
- 使用上面链接的预览说明中的链接,在 Eclipse 中安装 ADT 和 NDK 插件的预览版本。
- 重新创建我的项目,以便我可以重新执行“添加本机支持”步骤(显然需要修复工作)。
It's probably possible to accomplish #3 by editing appropriate project files rather than re-creating, but since I'm in early stages of development I didn't experiment with that.
可能可以通过编辑适当的项目文件而不是重新创建来完成 #3,但由于我处于开发的早期阶段,我没有对此进行试验。
回答by Evgeny Erlihman
Had the same issue, resolved it by fixing the path in project properties (C/C++ General / Paths and Symbols / Includes) from:
有同样的问题,通过修复项目属性(C/C++ General / Paths and Symbols / Includes)中的路径来解决它:
${NDKROOT}/sources/cxx-stl/gnu-libstdc++/include
${NDKROOT}/sources/cxx-stl/gnu-libstdc++/include
to:
到:
${NDKROOT}/sources/cxx-stl/gnu-libstdc++/4.6/include
${NDKROOT}/sources/cxx-stl/gnu-libstdc++/4.6/include
回答by Leo
Android NDK Project -> New -> Folder -> Advanced -> Link to alternate location(Linked Folder) Browser the path(for example):C:\cygwin\lib\gcc\i686-pc-cygwin\3.4.4\include. The path depends on the version of cygwin you use.
Android NDK Project -> New -> Folder -> Advanced -> Link to alter location(Linked Folder) 浏览路径(例如):C:\cygwin\lib\gcc\i686-pc-cygwin\3.4.4\include . 路径取决于您使用的 cygwin 版本。
回答by Honza
In current Android NDK (Revision 10e) folder gnu-libstdc++/4.6
does not exists - you have to change Eclipse build include paths:
在当前的 Android NDK(修订版 10e)文件夹gnu-libstdc++/4.6
中不存在 - 您必须更改 Eclipse 构建包含路径:
Project - Properties - C/C++ General - Paths and Symbols - Includes - GNU C, GNU C++
项目 - 属性 - C/C++ 常规 - 路径和符号 - 包含 - GNU C、GNU C++
${NDKROOT}/sources/cxx-stl/gnu-libstdc++/4.6/include
${NDKROOT}/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/include
Change to:
改成:
${NDKROOT}/sources/cxx-stl/gnu-libstdc++/4.8/include
${NDKROOT}/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include
回答by Victor Choy
1 close project. open .project in another editor. delete the following:
1 关闭项目。在另一个编辑器中打开 .project。删除以下内容:
......
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
......
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
......
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
2 delete .cproject
2 删除.cproject
3 open project in eclipse, refresh. Right click, properties->Android Tools -> Add Native Support. Solved, now we can ctrl + click to open link.
3 在eclipse中打开项目,刷新。右键单击,属性->Android 工具-> 添加本机支持。解决了,现在我们可以ctrl+点击打开链接了。
4 If methods and symbols still shows unresolved, you can try this: Go to the project's Properties -> C/C++ General -> Code Analysis. Click the "Use project settings" radio button (or "Configure Workspace Settings..." button). Disable (uncheck) the "Method cannot be resolved" checkbox.
4 如果方法和符号仍然显示未解析,您可以尝试以下方法:转到项目的属性-> C/C++ 常规-> 代码分析。单击“使用项目设置”单选按钮(或“配置工作区设置...”按钮)。禁用(取消选中)“无法解析方法”复选框。
回答by levis501
The only work around I've been able to find for this in my project is to disable the #include warnings in Eclipse Preferences -> General -> Editors -> Text Editors -> Annotations -> C/C++ Indexer Markers.
我能够在我的项目中找到的唯一解决方法是禁用 #include 警告 Eclipse Preferences -> General -> Editors -> Text Editors -> Annotations -> C/C++ Indexer Markers.
Since the C/C++ project preferences don't show up in Android projects, I haven't been able to enter include directories for the NDK code.
由于 C/C++ 项目首选项未显示在 Android 项目中,因此我无法输入 NDK 代码的包含目录。