将 STL 与 Android NDK 一起使用时出现 Eclipse 索引器错误 [英] Eclipse indexer errors when using STL with Android NDK

查看:27
本文介绍了将 STL 与 Android NDK 一起使用时出现 Eclipse 索引器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Ubuntu 上使用带有 Eclipse Indigo 的 Android NDK r7.我将我的 java 项目设置为使用 C++ 特性.我在 C++ 端使用 STL,所以我添加了

<块引用>

APP_STL := gnustl_static

在 Application.mk 文件中.

ndk-build 成功编译了我的代码并创建了一个共享对象.

但是 Eclipse 索引器抱怨缺少 STL 符号.例如

<块引用>

方法‘push_back’无法解析"符号‘向量’无法解析解决"

只有在编辑器中打开 C++ 文件时才会发生这种情况.最终eclipse不会创建我的apk.我添加了 ndk 附带的 gnu STL 头文件的路径(属性 => C/C++ 常规 => 代码分析 => 路径和符号):

<块引用>

android-ndk-r7/sources/cxx-stl/gnu-libstdc++/includeandroid-ndk-r7/sources/cxx-stl/gnu-libstdc++/include/bits

当前的解决方法是关闭打开的 C++ 文件以使 eclipse 快乐.

有趣的是,eclipse 索引器与在中找到的标题一起工作正常

<块引用>

android-ndk-r7/platforms/android-14/arch-arm/usr/include

有什么我忘记在 eclipse 中设置的吗?

解决方案

您必须将 STL 的路径添加到项目设置中,以便 Eclipse 也对其进行索引.项目-> 属性-> C/C++ 常规-> 包含.这是我添加的内容:

/sources/cxx-stl/gnu-libstdc++/include<path_to_NDK>/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/include<path_to_NDK>/platforms/android-9/arch-arm/usr/include

I'm using the Android NDK r7 with eclipse Indigo on Ubuntu. I set up my java project to use the C++ nature. I'm using STL on C++ side so I added

APP_STL := gnustl_static

in the Application.mk file.

ndk-build succeed compiling my code and creating a shared object.

However eclipse indexer complains about missing STL symbols. For example

"Method 'push_back' could not be resolved" "Symbol 'vector' could not be resolved"

This happens only when C++ files are open in the editor. Ultimately eclipse won't create my apk. I added path to the gnu STL headers shiped with the ndk (Properties => C/C++ General => Code Analasys => Path & symbols) :

android-ndk-r7/sources/cxx-stl/gnu-libstdc++/include
android-ndk-r7/sources/cxx-stl/gnu-libstdc++/include/bits

Current workaround is to close opened C++ files to make eclipse happy.

Interestingly eclipse indexer's working fine with headers found in

android-ndk-r7/platforms/android-14/arch-arm/usr/include

Is there something I forgot to set up in eclipse ?

解决方案

You have to add path to STL to project settings so that Eclipse indexes it as well. Project->Properties->C/C++ General->Includes. Here's what I have added:

<path_to_NDK>/sources/cxx-stl/gnu-libstdc++/include
<path_to_NDK>/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/include
<path_to_NDK>/platforms/android-9/arch-arm/usr/include

这篇关于将 STL 与 Android NDK 一起使用时出现 Eclipse 索引器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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