NetBeans not recognizing "cout"..Please Help!

I have not even really started to learn c++. I am still trying to setup NetBeans properly so I can practice/learn. It took me forever to get MiniGW and MSYS configured properly. Now I am trying to start following my book's tutorials and I'm stuck already. I have been trying different #include as well as several different variations like std::cout. Like I said before I am brand new at this, so please be patient. I am using NetBeans 8.0.2 on Windows 8.1.. Thanks

*
* File: newmain.c++
* Author: Matthew
*
* Created on May 31, 2015, 2:33 PM
*/

#include <cstdlib>

using namespace std;

/*
*
*/
int main(int argc, char** argv) {

return 0;
}
#include <iostream>

int main()
{
cout<<"Hello \n";
return 0
}
Last edited on
I'm not sure if it's on purpose, but you've posted two programs (neither of which uses code tags). The second one (starts at #include <iostream> ) will work if you put std:: in front of cout<< and a semi colon after return 0.
Last edited on
Your code is very very scruffy. Simply do this:

1
2
3
4
5
6
#include <iostream>

int main() {
     std::cout << "Hello\n";
     return 0;
}


If that still doesn't work, then you didn't configure Netbeans correctly. It is probably one of the more difficult ones to set up in my humble opinion.
Since you are using Windows, I would recommend VS. They do supply a completely free version.
If you are adamant on not using VS, you can try Code::Blocks.
Last edited on
As someone who's used both, I'd actually suggest starting with neither. If you can, try and get a version of Quincy as it starts completely set up and even allows you to use graphics from the get go. Personally, if you're going to go with a mainstream IDE, I'd really recommend Code::Blocks as it promotes multiplatform programming which is basically always a good thing.
Thank you for your responses. @rlc4 i tried running that and this was the result.. @shadowmouse i will download quincy now thanks.
______________________________________________________________________

#include <iostream>

int main()
{
std::cout << "Hello \n";
return 0;
}

______________________________________________________________________

"/C/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/c/Users/Matthew/Documents/NetBeansProjects/CppDynamicLibrary_1'
nbproject/Makefile-Debug.mk:73: warning: overriding commands for target `build/Debug/MinGW-Windows/newfile.o'
nbproject/Makefile-Debug.mk:68: warning: ignoring old commands for target `build/Debug/MinGW-Windows/newfile.o'
"/C/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/libCppDynamicLibrary_1.dll
make.exe[2]: Entering directory `/c/Users/Matthew/Documents/NetBeansProjects/CppDynamicLibrary_1'
nbproject/Makefile-Debug.mk:73: warning: overriding commands for target `build/Debug/MinGW-Windows/newfile.o'
nbproject/Makefile-Debug.mk:68: warning: ignoring old commands for target `build/Debug/MinGW-Windows/newfile.o'
mkdir -p build/Debug/MinGW-Windows
rm -f "build/Debug/MinGW-Windows/newfile.o.d"
g++ -c -g -MMD -MP -MF "build/Debug/MinGW-Windows/newfile.o.d" -o build/Debug/MinGW-Windows/newfile.o newfile.cpp
mkdir -p build/Debug/MinGW-Windows
rm -f "build/Debug/MinGW-Windows/newfile1.o.d"
g++ -c -g -MMD -MP -MF "build/Debug/MinGW-Windows/newfile1.o.d" -o build/Debug/MinGW-Windows/newfile1.o newfile1.c++
newfile1.c++: In function 'int main()':
newfile1.c++:4:5: error: 'cout' was not declared in this scope
cout << "Hello, World!\n";
^
make.exe[2]: *** [build/Debug/MinGW-Windows/newfile1.o] Error 1
make.exe[2]: Leaving directory `/c/Users/Matthew/Documents/NetBeansProjects/CppDynamicLibrary_1'
make.exe[1]: *** [.build-conf] Error 2
make.exe[1]: Leaving directory `/c/Users/Matthew/Documents/NetBeansProjects/CppDynamicLibrary_1'
make.exe": *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 4s)
Last edited on
But as far as I can tell, Quincy hasn't been updated since 2008 (and it was a very minor update at that). The development on it seems to have ceased, which is NOT a good thing. C++ has had 2 new standards released sense then (C++11 and C++14).

Though it is not a good idea to start off using OS-Dependent code (like system.sleep()), it also isn't a good idea to start off with worrying about multiplatforming.

For starting off, there really is no benefit to use C::B over VS (and the same can be said the other way around).
Last edited on
maathimself1;

Again, this seems to be a NetBeans oriented issue. After doing a bit of research, I found that the gcc compiler does not automatically include C++'s STL. g++ does, however.

Source: https://forums.netbeans.org/ptopic3245.html

If you need more assistance, you might find better help on NetBean's forums instead of here.

EDIT: Though, while looking through your output it looks like it is already using g++...
Last edited on
newfile1.c++: In function 'int main()':
newfile1.c++:4:5: error: 'cout' was not declared in this scope
cout << "Hello, World!\n";

Your project configuration seems to be incorrect
You have two files: newfile1.c++ and newfile.cpp. You showed the code for newfile.cpp, but the one at fault is newfile1.c++ (that doesn't qualify the namespace)

You don't need those two files, just remove newfile1.c++ from the project.
Topic archived. No new replies allowed.