Eclipse C++包含错误:没有这样的文件或目录
我已将 C++ 项目加载到 Eclipse (Europa) 中,并且正在熟悉 CDT 界面。
以下行有一个特别烦人的错误消息:
#include "somedir/somefile.h"
somedir/somefile.h:没有这样的文件或目录
包含文件存在于“/opt/local/project/include/somedir/somefile.h”中”。
在项目>下属性> C/C++ 通用 >路径和符号>包含,我已经添加了包含目录“/opt/local/project/include”。
然而,这似乎并不能解决问题。
有谁知道如何处理这个错误? 谢谢。
编辑: 解决了问题。事实证明这是一个简单的问题。我必须“刷新”工作区中的所有项目。
I've loaded a C++ project into Eclipse (Europa) and I'm familiarizing myself with the CDT interface.
There is one particularly annoying error message for the following line:
#include "somedir/somefile.h"
somedir/somefile.h: No such file or directory
The include file exists in "/opt/local/project/include/somedir/somefile.h".
Under Project > Properties > C/C++ General > Paths and Symbols > Includes, I've already added the include directory "/opt/local/project/include".
However, this does not seem to solve the issue.
Does anyone know how to deal with this error?
Thanks.
Edit:
Solved the problem. Turns out that it was a simple issue. I had to "refresh" all the projects in the workspace.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么要这么旧的版本?新版本的 Eclipse CDT 做出了巨大的改进。
这是一个非常明显的问题,但是在 Project > 下属性> C/C++ 通用 >路径和符号>包括(至少在当前的 CDT 中)每种语言(汇编、C 和 C++)都有单独的类别。您是否确保在 C 和 C++ 下添加 /opt/local/project/include (如果适用)?
或者,如果您的项目是使用 Make 构建的,那么只需从 Eclipse 中构建项目通常就会让 Eclipse 使用 Make 的输出自动检测包含目录,而无需您自己设置包含路径。
如果路径均设置正确,则索引相关问题的标准修复方法是右键单击项目,选择“索引”,然后选择“重建”。
Why such an old version? Newer versions of the Eclipse CDT have made vast improvements.
This is a really obvious question, but under Project > Properties > C/C++ General > Paths and Symbols > Includes (at least in the current CDT), there are separate categories for each language (assembly, C, and C++). Did you make sure to add /opt/local/project/include under both C and C++ (if appropriate)?
Alternatively, if your project is built using Make, then simply building your project from within Eclipse will often let Eclipse auto-detect include directories using Make's output, without your having to set the include paths yourself.
If the paths are all set up correctly, then the standard fix for indexing-related problems is to right-click on your project, choose Index, and choose Rebuild.
右键单击项目->索引->刷新所有文件。
Right Click on project -> Index -> Freshen All Files.