是什么导致Eclipse CDT无法解决的包含:< iostream> [英] What causes the Eclipse CDT Unresolved inclusion: <iostream>
问题描述
仅安装了最新的Eclipse IDE,并遵循随附的 C ++用户指南.
简单的应用程序已成功完成,但是一旦我进入 C ++文件教程,我收到了未解决的包含项:<iostream>
"错误,以及一堆与"cout,cin,endl"有关的其他错误,因为
我完全按照指示进行了教程,并且不确定为什么会发生这种情况.此后,我已经按照此答案进行了纠正,但现在想知道为什么会发生这种情况,特别是因为我正在遵循官方教程,并且是否必须为Eclipse上的每个项目添加C ++包含路径?
注释中链接的屏幕快照中的第一个错误提供了解决该问题的线索.
如果转到错误的位置"中提到的首选项页面,则会看到有一个名为获取编译器规范的命令"的字段,其内容类似于:
${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"
这是Eclipse尝试运行的命令,以使编译器输出其内置的include路径和其他类似信息.
出现错误Program "-E" not found in PATH
的事实表明变量${COMMAND}
和${FLAGS}
的计算结果为空字符串,因此命令中的第一个实际标记(然后,shell尝试将其解释为程序名称)为-E
.
我不确定为什么这些变量的值是否为空,但是您应该可以通过将${COMMAND}
替换为g++
(大概是g++
在您的计算机中)来解决此问题.路径).
Just installed the latest Eclipse IDE and am following the included C++ User Guide right from 'Before you begin' section.
The simple application was successfully completed but once I got to the makefile project and the C++ file tutorials, I got the "Unresolved inclusion: <iostream>
" error and a bunch of others related to "cout, cin, endl" because of it.
I followed the tutorials exactly as instructed and am not sure why this occurred. I have since corrected it by following this answer, but now want to know why this happens, especially since I am following the official tutorial and do I have to add the C++ include path for every project on Eclipse?
That first error in the screenshot linked in the comments provides a clue to the problem.
If you go to the preference page mentioned in the error's "Location", you'll see that there is a field called "Command to get compiler specs" with the contents something like:
${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"
This is a command that Eclipse tries to run to get your compiler to output its built-in include paths and other similar information.
The fact that you're getting the error Program "-E" not found in PATH
suggests that the variables ${COMMAND}
and ${FLAGS}
are evaluating to empty strings, so that the first actual token in the command (which the shell then tries to interpret as the program name) is -E
.
I'm not sure why those variables are evaluating to empty, but you should be able to work around the issue by replacing ${COMMAND}
with g++
(presumably g++
is in your PATH).
这篇关于是什么导致Eclipse CDT无法解决的包含:< iostream>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!