Eclipse C++ 包含错误:没有这样的文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3479163/
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
Eclipse C++ include error: no such file or directory
提问by Jin Kim
I've loaded a C++ project into Eclipse (Europa) and I'm familiarizing myself with the CDT interface.
我已经将一个 C++ 项目加载到 Eclipse (Europa) 中,并且我正在熟悉 CDT 界面。
There is one particularly annoying error message for the following line:
以下行有一条特别烦人的错误消息:
#include "somedir/somefile.h"
somedir/somefile.h: No such file or directory
somedir/somefile.h: 没有那个文件或目录
The include file exists in "/opt/local/project/include/somedir/somefile.h".
包含文件存在于“/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".
在Project > Properties > C/C++ General > Paths and Symbols > Includes 下,我已经添加了包含目录“/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.
编辑:解决了问题。原来这是一个简单的问题。我必须“刷新”工作区中的所有项目。
回答by Josh Kelley
Why such an old version? Newer versions of the Eclipse CDT have made vast improvements.
为什么是这么老的版本?较新版本的 Eclipse CDT 进行了大量改进。
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)?
这是一个非常明显的问题,但是在 Project > Properties > C/C++ General > Paths and Symbols > Includes(至少在当前 CDT 中)下,每种语言(汇编、C 和 C++)都有单独的类别。您是否确保在 C 和 C++ 下添加 /opt/local/project/include (如果适用)?
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.
或者,如果您的项目是使用 Make 构建的,那么简单地从 Eclipse 内构建您的项目通常会让 Eclipse 使用 Make 的输出自动检测包含目录,而无需您自己设置包含路径。
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.
如果所有路径都设置正确,则索引相关问题的标准修复方法是右键单击您的项目,选择索引,然后选择重建。
回答by Rishiaar
Right Click on project -> Index -> Freshen All Files.
右键单击项目 -> 索引 -> 刷新所有文件。