Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Symbol 'cout' could not be resolved
Symbol 'cout' could not be resolved [message #1080966] Tue, 06 August 2013 16:12 Go to next message
Eclipse UserFriend
Hello,

I'm starting with Eclipse, but I cannot seem to be able to compile a
simple C++ Hello World program. On build, I have 2 errors:

Symbol 'cout' could not be resolved
Symbol 'endl' could not be resolved



I'm running:

* IDE: Eclipse-CDT, Version: Kepler Release, Build id: 20130614-0229 32-
bits
* JAVA: JRE 32-bits 1.7.0_25-b17
* Toolchain: MinGw: mingw-get-inst-20120426.exe with compilers for C, C+
+, and MSYS Basic System
* OS: Windows 7 Professional 64-bits


The program:
=========== START ============
#include <iostream>
using namespace std;
int main() {
std::cout << "!!!Hello World!!!" << std::endl; // prints !!!Hello
World!!!
return 0;
}
=========== END ============

I'm using toolchain MinGW GCC, with CDT Internal Builder. Environment
variables are:

MINGW_HOME = C:\MinGW

MSYS_HOME = C:\MinGW\msys\1.0

PATH = ${MINGW_HOME}\bin;${MSYS_HOME}\bin;C:/Program Files (x86)/Java/jre7/
bin/client;C:/Program Files (x86)/Java/jre7/bin;C:/Program Files (x86)/
Java/jre7/lib/i386;;C:\Program Files (x86)\GTK2-Runtime\bin;C:\eclipse;
(etc)

Om C/C++ Build > Settings > Tool Settings > GCC C++ Compiler > Includes I
have added C:\MinGW\lib\gcc\mingw32\4.6.2\include\c++\

Everything else is set to defaults.

When I save and build the project, I get

09:32:32 **** Incremental Build of configuration Debug for project
Eclipse-002 ****
Info: Internal Builder is used for build
g++ -O0 -g3 -Wall -c -fmessage-length=0 -o "src\\Eclipse-002.o" "..\\src\
\Eclipse-002.cpp"

09:32:32 Build Finished (took 90ms)

Unresolved Inclusions shows <iostream>, even though it's located at C:
\MinGW\lib\gcc\mingw32\4.6.2\include\c++\ and it's part of the GCC C++
includes.


I've been googling for a couple of days with no luck. I've removed
Eclipse, installed it from scratch. I had Cygwin installed besides MinGw
and I removed it. I've tried with "std::cout" and without "std::" .

I'm sure I'm overlooking something simple :/

Thank you in advance.
--
Sinner
Re: Symbol 'cout' could not be resolved [message #1081502 is a reply to message #1080966] Wed, 07 August 2013 09:53 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
That is *not* a compiler error. It is an error from the static code analyzer. In the Problems View you can distinguish between compiler and code analyzer errors via the column problem type. In the editor there are different icons.
But back to your problem. In your case it is a false warning. The code analyzer (CODAN) does not recognize the symbol "cout" because it does not find the system includes (iostream). Eclipse usually automatically finds the correct system includes (so need for you to add them in C/C++ Build > Settings > Tool Settings > GCC C++ Compiler > Includes ). However, to find these includes Eclipse needs to know where MinGW is installed. You correctly configured environment variables for MinGW. But there is a bug with respect to the scanner discovery in Eclipse (the part that looks for the system includes etc.). It seems to ignore your PATH settings. I would suggest that you modify the PATH variable in Windows directly and then start Eclipse. Then you should rebuild the index (Project->Index->rebuild).


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Symbol 'cout' could not be resolved [message #1081813 is a reply to message #1081502] Wed, 07 August 2013 18:25 Go to previous message
Eclipse UserFriend
On Wed, 07 Aug 2013 11:53:18 +0200, Axel Mueller wrote:

> That is *not* a compiler error. It is an error from the static code
> analyzer. In the Problems View you can distinguish between compiler and
> code analyzer errors via the column problem type. In the editor there
> are different icons.
> But back to your problem. In your case it is a false warning. The code
> analyzer (CODAN) does not recognize the symbol "cout" because it does
> not find the system includes (iostream). Eclipse usually automatically
> finds the correct system includes (so need for you to add them in C/C++
> Build > Settings > Tool Settings > GCC C++ Compiler > Includes ).
> However, to find these includes Eclipse needs to know where MinGW is
> installed. You correctly configured environment variables for MinGW. But
> there is a bug with respect to the scanner discovery in Eclipse (the
> part that looks for the system includes etc.). It seems to ignore your
> PATH settings. I would suggest that you modify the PATH variable in
> Windows directly and then start Eclipse. Then you should rebuild the
> index (Project->Index->rebuild).

Axel,

Thank you for your message.

You were correct: not a compiler problem, it was a PATH problem with MinGW.

In the end I had to remove MinGW and install it from scratch, as the very
slow pipe to the Internet messed up the installation several times.

Now, with a complete (so far!) install of MinGW I can compile and run
projects from Eclipse.

Thank you again.

--
Salut,
Sinner
Previous Topic:Syntax Highlighting Oddities
Next Topic:linking with depending libraries
Goto Forum:
  


Current Time: Fri Dec 19 07:19:04 GMT 2014

Powered by FUDForum. Page generated in 0.87658 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software