Eclipse C++包含错误:没有这样的文件或目录

发布于 2024-09-14 09:58:33 字数 461 浏览 2 评论 0原文

我已将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半葬歌 2024-09-21 09:58:33

为什么要这么旧的版本?新版本的 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.

终遇你 2024-09-21 09:58:33

右键单击项目->索引->刷新所有文件。

Right Click on project -> Index -> Freshen All Files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文