Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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. 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". 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.

I just freshly installed Netbeans 8.0 and the latest cygwin version to try to fix this, but to no avail. I'm running Windows 7. Please help, it would be greatly appreciated.

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".

like image 400
user2628156 Avatar asked Apr 14 '14 04:04

user2628156


2 Answers

I just had the same experience with Netbeans (8.0.2) not being able to find includes ("Cannot find include file") on 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. Select the newly configured toolset as default and/or delete the old one to reduce confusion.

enter image description here

  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.

like image 151
mydoghasworms Avatar answered Nov 19 '22 08:11

mydoghasworms


I also had this problem (Cannot find include file iostream) in NetBeans IDE 8.1. I solved as follows:

Project properties -> Build -> C++ Compiler -> Basic Options -> C++ Standard -> C++98 or C++11 or C++14

This is the window

like image 24
kelvincer Avatar answered Nov 19 '22 08:11

kelvincer