Eclipse 编译成功但仍然出现语义错误 [英] Eclipse compiles successfully but still gives semantic errors

查看:34
本文介绍了Eclipse 编译成功但仍然出现语义错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:这显然是 StackOverflow 上的一个反复出现的问题,但是 - 就我所见 - 要么人们永远找不到方法,要么他们的解决方案对我不起作用

我正在使用 Eclipse Juno ADT.一切正常,直到我尝试更新 NDK.我用新版本(即 ndk-r8e)替换了我的 ndk 文件夹(即 ndk-r8d),并且在我的 Paths and Symbols 配置,我将包含从 g++ 4.6 更改为 4.7.

I am using Eclipse Juno ADT. Everything was working fine until I tried to update the NDK. I replaced my ndk folder (that was the ndk-r8d) by the new version (i.e. ndk-r8e) and, in my Paths and Symbols configuration, I changed the includes to go from g++ 4.6 to 4.7.

它似乎破坏了我的索引:我可以编译我的代码,但是 Eclipse 给出了语义错误,就像在 [1] 和 [2].错误主要来自OpenCV4Android使用的符号,例如distance、<代码>pt、queryIdxtrainIdx.

It seemed to break my index: I could compile my code, but Eclipse was giving semantic errors, exactly like in [1] and [2]. The errors mainly come from symbol used by OpenCV4Android, such as distance, pt, queryIdx and trainIdx.

当我尝试备份到我的旧配置时,索引仍然损坏!我找不到改变这一点的方法.

When I tried to backup to my old configuration, the index was still broken! I cannot find a way to change this.

  • 清理项目
  • 重建、刷新和索引"子菜单中的所有其他选项(当右键单击"项目时)
  • 在首选项中禁用/启用索引器
  • 验证诸如 trainIdx 之类的符号是否仅出现在我的 OpenCV4Android 包含的 Paths and Symbols 部分中.
  • 更改我在 Paths and Symbols 部分中的包含顺序.我基本上尝试将 OpenCV 包含在开头和结尾.
  • Clean up the project
  • Rebuild, refresh, and all the other options in the "Index" submenu (when "right-clicking" on the project)
  • Disable / enable the indexer in the preferences
  • Verify that symbols such as trainIdx only appear in my OpenCV4Android include in the Paths and Symbols section.
  • Change the order of my includes in the Paths and Symbols section. I basically tried to put the OpenCV include in the beginning and in the end.

我假设它是 CDT 索引,原因如下:

I assume that it is the CDT index because of the following:

  • 在命令行中,我可以使用 ndk-build cleanndk-build 构建我的项目.
  • 当我启动 Eclipse 时,直到我打开一个 C++ 文件(来自 jni 文件夹)之前,我都没有错误.
  • 我总是可以构建项目,但是只要我打开了一个C++文件,我就不能再运行应用程序了,因为很多Field ''无法解析.
  • 如果我不打开 C++ 文件,Eclipse 不会报告任何错误并且可以成功构建和部署 Android 应用程序.
  • In command line, I can build my project using ndk-build clean and ndk-build.
  • When I start Eclipse, I have no error until I open a C++ file (from the jni folder).
  • I can always build the project, but as long as I have opened a C++ file, I can't run the application anymore because of a lot of Field '<name>' could not be resolved.
  • If I don't open the C++ files, Eclipse doesn't report any error and can build and deploy the Android application successfully.

以下代码在linequeryIdxpt上报错:

The following code reports errors on line, queryIdx, pt:

cv::line(mRgb, keypointsA[matches[i].queryIdx].pt, keypointsB[matches[i].trainIdx].pt, cv::Scalar(255, 0, 0, 255), 1, 8, 0);

如果我写成这样,它就起作用了:

If I write it as follows, it works:

cv::DMatch tmpMatch = matches[i];
cv::KeyPoint queryKp = keypointsA[tmpMatch.queryIdx];
cv::KeyPoint trainKp = keypointsB[tmpMatch.trainIdx];
cv::line(mRgb, queryKp.pt, trainKp.pt, cv::Scalar(255, 0, 0, 255), 1, 8, 0);

并不是所有的 OpenCV 函数都没有解析:只有 ptqueryIdxtrainIdx.

It is not that all of the OpenCV functions are unresolved: only pt, queryIdx and trainIdx are.

任何评论将不胜感激.

推荐答案

在您在 Eclipse 环境中选择的项目首选项中,转到 C/C++ General -> Code Analysis -> Launching.确保两个复选框都未选中.关闭并重新打开项目或重新启动 eclipse 并重建项目.

In your selected project preferences within the Eclipse environment, go to C/C++ General -> Code Analysis -> Launching. Make sure that both check boxes are unchecked. Close and reopen the project or restart eclipse and rebuild the project.

这篇关于Eclipse 编译成功但仍然出现语义错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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