Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsSymbol 'cout' could not be resolved
https://www.eclipse.org/forums/index.php/mv/msg/500293/1080966/#msg_1080966
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:
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]]>2013-08-06T16:12:49-00:00Re: Symbol 'cout' could not be resolved
https://www.eclipse.org/forums/index.php/mv/msg/500293/1081502/#msg_1081502
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 Mueller2013-08-07T09:53:18-00:00Re: Symbol 'cout' could not be resolved
https://www.eclipse.org/forums/index.php/mv/msg/500293/1081813/#msg_1081813
> 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.