简体   繁体   English

Netbeans:找不到包含文件 <iostream> ,也无法解析标识符std,cout

[英]Netbeans: cannot find include file <iostream>, also, unable to resolve identifier std, cout

I'm receiving the above errors on all my C++ projects on Netbeans. 我在Netbeans上的所有C ++项目中都收到了上述错误。 I also receive cannot find errors for anything else I try to include. 我也收到了我试图包含的其他任何错误。 Here's what it says when I hold control and hover over it: http://imgur.com/bBF2xuB . 以下是我控制并将鼠标悬停在它上面时的内容: http//imgur.com/bBF2xuB One of the projects actually builds and runs just fine, but all the rest fail either with "build failed, exit value 2" or the run fails with "run failed, exit value 127". 其中一个项目实际构建并运行得很好,但所有其他项目都失败了“构建失败,退出值2”或运行失败,“运行失败,退出值127”。 I have absolutely no idea how to fix this and everything I've looked up to try to solve this hasn't helped. 我完全不知道如何解决这个问题以及我所寻求的所有尝试解决的问题都没有帮助。 This wasn't a problem a few months ago when I was using Netbeans, and I'm not sure why the problem spontaneously popped up. 几个月前,当我使用Netbeans时,这不是问题,我不确定为什么问题会自发地出现。

I just freshly installed Netbeans 8.0 and the latest cygwin version to try to fix this, but to no avail. 我刚刚安装了Netbeans 8.0和最新的cygwin版本试图解决这个问题,但无济于事。 I'm running Windows 7. Please help, it would be greatly appreciated. 我正在运行Windows 7.请帮忙,我将不胜感激。

EDIT The highlighted red errors in the attached photo are files/folders that do not actually exist. 编辑附加照片中突出显示的红色错误是实际不存在的文件/文件夹。 Could this be the problem, and if so, how can I go about fixing it? 这可能是问题,如果是这样,我该怎么办呢?

EDIT 2 I deleted or changed some of the non-existent file/folder paths in the code assistance tab under the C/C++ tab under the options, this seems to have made some of the errors in the editor go away, but I still cannot build the project (and the errors haven't disappeared on this specific project), and the projects that I created in the past that used to work just fine are building, but I'm still receiving "RUN FAILED exit value 127". 编辑2我在选项下的C / C ++选项卡下的代码辅助选项卡中删除或更改了一些不存在的文件/文件夹路径,这似乎使编辑器中的一些错误消失了,但我仍然无法做到构建项目(错误并没有消失在这个特定项目上),我过去创建的项目过去工作得很好,但我仍然收到“RUN FAILED退出值127”。

I just had the same experience with Netbeans (8.0.2) not being able to find includes ("Cannot find include file") on Linux. 我刚刚在Netbeans(8.0.2)上遇到过无法在Linux上找到包含(“找不到包含文件”)的经验。

I had to do the following: 我必须做以下事情:

  1. In the "Build Tools" tab under "C/C++" settings, click "Restore Defaults" to let it rescan for the tools, after which it picked up the paths to all the executables. 在“C / C ++”设置下的“构建工具”选项卡中,单击“恢复默认值”以使其重新扫描工具,然后选择所有可执行文件的路径。 Select the newly configured toolset as default and/or delete the old one to reduce confusion. 选择新配置的工具集作为默认值和/或删除旧工具集以减少混淆。

在此输入图像描述

  1. Under "Code Assistance", make sure the correct tool collection is selected, then click "Reset Settings" and "Apply". 在“代码帮助”下,确保选择了正确的工具集,然后单击“重置设置”和“应用”。 This populated all the necessary paths. 这填补了所有必要的路径。

  1. In my project settings, made sure I was using the right (newly discovered) tool collection. 在我的项目设置中,确保我使用了正确的(新发现的)工具集合。

After this, all the includes were picked up correctly and errors disappeared from the source checking. 在此之后,所有包含都被正确拾取并且错误从源检查中消失。

I also had this problem (Cannot find include file iostream) in NetBeans IDE 8.1. 我在NetBeans IDE 8.1中也遇到了这个问题(找不到包含文件iostream)。 I solved as follows: 我解决了如下:

Project properties -> Build -> C++ Compiler -> Basic Options -> C++ Standard -> C++98 or C++11 or C++14 项目属性 - >构建 - > C ++编译器 - >基本选项 - > C ++标准 - > C ++ 98或C ++ 11或C ++ 14

这是窗口

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM