如何去除错误“未解决的包含"用于 Eclipse IDE 中用户定义的路径 [英] How to remove error "unresolved inclusion" for user defined path in eclipse IDE

查看:35
本文介绍了如何去除错误“未解决的包含"用于 Eclipse IDE 中用户定义的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将现有的 ARM 的 IAR C++ 项目导入到 Eclipse IDE 中,并为 IAR 工具链添加了插件.该项目已导入,但某些文件未包含在内.它给出了错误:未解决的包含"并且文本带有红色下划线.我已经为这些文件添加了路径,如下所示,但仍然存在相同的错误.请建议删除此错误.

i have imported existing IAR C++ Project for ARM into eclipse IDE , with plugin added for IAR tool chain. The project got imported , but some files are not getting included. It gives error :Unresolved inclusion" and text is underlined with red color. I have added path for these files as shown below but still same error is there . Please suggest for removing this error.

推荐答案

您需要正确配置 Eclipse 的索引器.如果您的项目类型是Makefile 项目"(因此不是任何托管"类型,您可以在 Eclipse 中输入编译选项/标志),您可以按如下所述进行操作.

You need to configure Eclipse's indexer properly. If your project's type is "Makefile project" (so not any "managed" type, where you enter the compilation options/flags in Eclipse) you can do that as described below.

转到项目的属性,然后C/C++ 常规">预处理器包含路径、宏等".并切换到提供者"选项卡.取消选中以下所有内容:

Go to your project's properties, then "C/C++ General" > "Preprocessor Include Paths, Macros etc." and switch to "Providers" tab. Uncheck everything other than:

  • CDT GCC 构建输出解析器,
  • CDT Cross GCC 内置编译器设置(取决于您的项目的确切类型,这应该是其他类型 - 对于Cross GCC"项目,您选择... Cross GCC ..."复选框).

如下图所示进行配置:

在第一种情况下,您替换:

In the first case you replace:

(gcc)|([gc]\+\+)|(clang)

与:

.*((gcc)|([gc]\+\+)|(clang))

这样 Eclipse 就会知道所有以... arm-none-eabi-gcc ..."或... arm-none-eabi-g++ ..."开头的行都是编译器调用,所以它将能够解析标志,包括包含路径(-I 标志).您可以更改选项文件/文件夹/项目 - 取决于您的配置.

This way Eclipse will know that all your lines starting with "... arm-none-eabi-gcc ..." or "... arm-none-eabi-g++ ..." are compiler invocations, so it will be able to parse the flags, including the include paths (-I flags). You can alter the options File/Folder/Project - depending on your configuration.

在第二种情况下,您将文本框中的内容替换为类似于:

In the second case you replace what's in the textbox with something similar to:

arm-none-eabi-${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}" -std=gnu++11 -std=gnu99 -mcpu=cortex-m4 -mthumb

并且您需要根据您的项目指定适当的标志.您只输入与内置编译器设置"相关的标志 - 它们是 -std、-mcpu、-mthumb、-mfpu 等.如您所见,您应该为 C 和 C++ 输入标志(如果您使用C++).

And you need to specify proper flags, depending on your project. You enter only the flags that matter for the "built-in compiler settings" - these are -std, -mcpu, -mthumb, -mfpu, etc. As you see, you should enter flags for both C and C++ (if you use C++).

当然,如果您的编译器前缀不是arm-none-eabi-",您应该相应地修改选项.

Of course if your compiler prefix is not "arm-none-eabi-" you should modify the options accordingly.

之后,您应该完全重建您的项目,以便 Eclipse 能够看到您项目中所有文件的所有编译命令.如果你的 makefile 隐藏了实际的命令(例如它只显示CC:some_file.c"而不是实际执行的完整命令)这个功能必须被禁用(你可以改变在C"下的项目属性中调用 make 的方式/C++ 构建"在构建(增量构建)"文本框中的行为"选项卡中.

After that you should do a full rebuild of your project, so that Eclipse would be able to see ALL compilation commands for ALL files from your project. If your makefile hides the actual commands (for example it displays only "CC: some_file.c" instead of full command that is actually executed) this feature has to be disabled (you can alter the way make is invoked in project's properties under "C/C++ Build" in "Behavior" tab in "Build (incremental build)" textbox).

有时还需要手动重建索引,因此右键单击您的项目并转到索引">重建"(有时其他选项也有帮助).关闭所有编辑器,甚至可能关闭项目,重新打开后应该就可以了.

Sometimes it is also necessary to rebuild index manually, so right-click your project and go to "Index" > "Rebuild" (sometimes other options help too). Close all editors, maybe even close the project, and after reopening it should be OK.

完成所有这些步骤后,您应该在源(或文件夹或整个项目 - 取决于您在解析器中选择的内容)上看到一个小的扳手"图标 - 用右键单击此类元素后,选择属性和C/C++ 常规">预处理器包括路径、宏等."您应该能够看到 Eclipse 在那里发现了什么:

After all these steps you should see a small "wrench" icons on your sources (or folders or whole project - depending on what you selected in the parser) - after you click such element with right button, select Properties and "C/C++ General" > "Preprocessor Include Paths, Macros etc." you should be able to see what Eclipse discovered there:

这篇关于如何去除错误“未解决的包含"用于 Eclipse IDE 中用户定义的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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