Eclipse中无法找到,即使包含路径已经设置头文件管理器 [英] Eclipse can't find header filers even though include paths have been set

查看:1928
本文介绍了Eclipse中无法找到,即使包含路径已经设置头文件管理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在创建中使用GCC特定的Eclipse环境中一个新的C项目,我碰到一个特殊的连接问题:

When creating a new C project in a particular Eclipse environment which uses GCC, I run into a peculiar linker problem:

致命错误:my_header.h:没有这样的文件或目录

Fatal error: my_header.h: No such file or directory.

我得到这个问题,因为my_header.h驻留在子文件夹中。经过调查,我发现,你需要包括在GCC子文件夹包含路径(选项 -I )。如何做到这一点似乎不同的Eclipse实现之间有所不同,但它应该是这样的。

I get this problem since "my_header.h" resides in a sub folder. After investigation, I found out that you need to include sub folders in the GCC include path (option -I). How this is done seems to vary between different Eclipse implementations, but it should be something like

项目 - >属性 - > C / C ++编译 - >设置 - >编译器 - >包括

Project -> Properties -> C/C++ Build -> Settings -> Compiler -> Includes

在哪里编译可能有不同的实现方式不同的名字,包括可以被称为输入或类似。

Where "compiler" may have a different name in different implementations, and "includes" may be called "input" or similar.

有应通过单击添加图标,添加包含路径(选项 -I ),您可以相对于特定项目的路径设置,选项其次是工作区按钮,然后选择目录。日食然后生成一个路径,它应该是这个样子。

There should be an option to add the include path (option -I) where you can set the path relative to the specific project, by clicking an "Add" icon followed by Workspace button, then select the directory. Eclipse then generates a path, which should look something like

$ {workspace_loc:/ $ {} ProjName /应用}

执行此操作为项目中的所有子文件夹(及其子文件夹)。

Do this for all sub folders in the project (and their sub folders).

不过,尽管做了上述相关文件夹,我仍然得到没有这样的文件或目录错误。可能是什么问题?

But despite doing the above for the relevant folder, I still get the "no such file or directory" error. What could be the problem?

(我张贴这种问答集,因为我想分享这个问题与其他人的解决方案的样式)

(I'm posting this Q&A style since I want to share the solution of this problem with others)

推荐答案

这样做的原因的错误是没有为海湾合作委员会没有仔细的检查包括路径。尽管给予描述到Eclipse相对路径,Eclipse会依然传递给GCC的绝对路径 -I

The reason for this error is that there is no sanity check for the gcc include path. Despite giving a relative path to Eclipse as described, Eclipse will still pass an absolute path to gcc -I.

假设你把你的项目位于喜欢的路径:

Suppose you have your project located at a path like:

C:\åäö\workspace\project

和位于

C:\åäö\workspace\project\std

,其中AAO是包含任何非标准ASCII字符的字符串。在这个例子中,我用瑞典语,但你会遇到大多数语言这样的非标准字母(法语,德语,西班牙语等)。

where "åäö" is any string containing any non-standard ASCII letters. In this example I used Swedish, but you'll encounter such non-standard letters in most languages (French, German, Spanish etc).

问题是,通过Eclipse的完整路径,而不是相对一个GCC,然后有某种符号表不幸的事。因此,而不是得到预期的

The problem is that Eclipse passes the full path, rather than the relative one to GCC, and then there is some sort of symbol table mishap. So rather than getting the expected

-I"C:\åäö\workspace\project\std"

你可能会得到随机的字母垃圾,如:

you might get random garbage letters such as:

-I"C:\@!#\workspace\project\std"

的路径没有意义和包含路径是不理智检查,所以你没有诊断告诉你这一点,除非你仔细阅读控制台输出。取而代之的是,Eclipse默默$,它已经增加include路径到它应该检查的路径列表,即使它不是p $ ptends。

The path doesn't make sense and the include path is not sanity checked, so you get no diagnostic telling you about this, unless you read the console output in detail. Instead, Eclipse silently pretends that it has added your include path to the list of paths it should check, even though it has not.

唯一的解决办法似乎是避免将您的项目下面包含非ASCII字符的路径。这似乎认为这是在使用GCC的Eclipse的几种实现的bug。

The only solution seems to be avoiding placing your projects below paths that contain non-ASCII letters. It would seem that this is a bug in several implementations of Eclipse that use GCC.

这篇关于Eclipse中无法找到,即使包含路径已经设置头文件管理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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