3

I was trying to run following code in eclipse in ubuntu 12.04 but It keeps giving me error. could you please tell me why this is happening ? Thanks.

 #include <iostream> using namespace std; int main() { cout << "Hello World!" << endl; return 0; } 

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

6
  • But it compiles the code OK and the code runs? It's most likely the toolchain not set-up correctly within eclipse. Commented Apr 30, 2012 at 6:46
  • When I click "build project" under project in the menu bar, it gives me this problem.. So It doesn't run.. Do I need to change something in eclipse ? Thanks. Commented Apr 30, 2012 at 8:59
  • Try it from the command line first to make sure all necessary packages are installed. Commented Apr 30, 2012 at 9:06
  • I am sorry.. I have never used C++ in command line.. Thanks.. Commented Apr 30, 2012 at 9:08
  • g++ -o myprog myprog.cpp (where myprog.cpp is the name of the source file you posted). Commented Apr 30, 2012 at 9:32

1 Answer 1

5

This is the C++ parser of Eclipse who can't find the symbols.

You could add the config to your already created project but it can be painful. So simply create a new C++ project :

File > New > C++ Project

Then :

Pick the type of project you want, like "Executable > Empty Project" (or maybe "Makefile Project > Empty Project") and make sure to select Linux GCC in the Toolchains. This will add all the default includes in the configuration so that the C++ parser finds everything. Click Finish, paste your code in a C++ file and enjoy.

For information, you can see these include paths in the Project Properties > C/C++ General > Paths and Symbols > Includes > GNU C++.

Sign up to request clarification or add additional context in comments.

1 Comment

if you are sure you have all the path set correctly, create new project this makes Eclipse pick up all the necessary setting,

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.