即使设置了包含路径,Eclipse也无法找到头文件 [英] Eclipse can't find header file, even though include paths are set

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

问题描述

这是我们已经处理了一段时间的问题-我们正在使用Cygwin工具链构建一个C ++项目,无论我们在C ++编译器中添加的内容包括项目设置下的路径,Eclipse都无法似乎找到了必要的头文件.

This was an issue we've been dealing with for a while now - we're building a C++ project using the Cygwin toolchain, and no matter what we add in the C++ compiler include paths under project settings, Eclipse can't seem to find the necessary header files.

到目前为止,我们已经完成了Stackoverflow社区建议的所有工作;

We have done everything the Stackoverflow community has suggested so far;

  • 确保包含路径是相对于工作空间的
  • 尝试了反斜杠和正斜杠
  • 尝试使用特定于Cygwin的路径(/cygdrive/c代替C:/)
  • 检查了编译器的输出以验证包含路径是否存在
  • 检查生成的makefile以确保它们正确
  • 重建索引
  • 完全删除了调试文件夹
  • 重新启动Eclipse

基本上只是更改 #include< ...> 代码本身以使用完整路径(C:/.../file.h)工作.这不能满足我们的需求,因为我们需要多个开发人员才能进行此项目,并且文件本身是根据某些构建过程而动态生成的.

Basically nothing short of changing the #include <...> code itself to use a full path (C:/.../file.h) worked. This doesn't work for our needs as we need multiple developers to be able to work on this project, and the files themselves are generated dynamically as a result of some of our build procedures.

推荐答案

因此,这里有一个关于Eclipse的有趣的小细节,我们不知道-特定的源文件本身可以有自己的设置.

So here's a fun little detail about Eclipse we didn't know - specific source files themselves can have their own settings.

如果您查看源文件并看到以下扳手图标,则表明该文件具有某些设置,这些设置可能与您的项目特定设置相反.

If you look at your source files and see the following wrench icon, this means that file has some settings which may be contrary to your project-specific settings.

结果,我们特定于源的设置将覆盖包含路径,因此对于这些文件,找不到任何标头.最好的部分是Eclipse不会以任何比这更明确的方式告诉您-扳手图标没有提供工具提示来解释正在发生的事情.

As a result, our source-specific settings were overriding the include paths, so for those files, none of the headers could be found. The best part is that Eclipse doesn't tell you in any way more explicit than this - the wrench icon does not offer a tool-tip to explain what's going on.

Simply right click on the file > go to Resource Configurations > Reset to Default...

现在,只要您在项目设置中编写了正确的包含路径,就可以找到您的头文件.

Your header files will be found now, provided that you've written the correct include paths in your project settings.

作为参考,我们使用的是Eclipse Kepler-我不确定他们是否已解决此问题,并在较新版本中为用户添加了更多信息.

For reference, we're using Eclipse Kepler - I'm not sure if they fixed this and added more info for users in newer versions.

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

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