6

Trying to get Eclipse CDT plugin to compile a simple C++ app. I create a new C++ project, and add 1 file (test.cpp) and code it up like a "Hello, world!" example:

#include <iostream>
using namespace std;

int main()
{
    cout << "Hello, world!";
    return 0;
}

I get highlighted syntax errors on using namespace std and cout, stating (respectively):

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

I'm sure I didn't install CDT with everything it needed to compile/build a full C++ app. Where could I start looking to figure out what I'm missing?

IAmYourFaja
  • 55,468
  • 181
  • 466
  • 756
  • what platform Windoze, Linux, Mac? – macduff Feb 20 '12 at 21:59
  • I'm on Windows 7 (not by choice!) – IAmYourFaja Feb 20 '12 at 21:59
  • Symbol 'std' could not be resolved - it's compiler error or eclipse indexer/autocomplete error message? – Torsten Feb 20 '12 at 22:17
  • This is a highlighted error in the Eclipse editor. The error message shows up on the Problems view/window under the Errors category. So, technically, its an eclipse/autocomplete error, but I believe its because I don't have the right dependencies configured. But not sure where to start. – IAmYourFaja Feb 20 '12 at 22:22

2 Answers2

3

Do you have a compiler? Quoting eclipse documentation: 'Eclipse IDE for C/C++ Developers does not contain a compiler or debugger; if your system does not have one, you need to download and install one. Please see the Before you begin section of the C/C++ Development User Guide.'

There you can choose and find out how to install a compiler.

Specifically for your unresolved symbols problem, you need to have correct paths set in Project->Properties->C/C++ General->Paths and Symbols/Includes tab, which depends on the compiler you choose to install.

ondrisko
  • 320
  • 2
  • 11
0

I don't know what OS you have, but if you are on a Mac, the following worked for me:

  1. Verify Xcode is installed.

  2. Open your Terminal window and type:

    xcode-select --install

Now the "'std' could not be resolved" error should disappear.

Now, to run your Hello World application:

  1. Click the Run icon. You are then prompted to select your Run Configuration. The Run Configuration window can also be reached by clicking the drop down arrow from the Run Icon or using the Run menu.

  2. Your configuration should be for a C++ Application. On the "Main" tab, click the "Search Project" button.

  3. In the Binaries box, there should be a binary with the name of your project pre-selected. Click OK.

  4. Click the Run button at the bottom of the "Run Configurations" window.

Hopefully your project then runs, and you see "Hello, world!" in the Console window at the bottom of Eclipse.

I would also like to add, I still have issues sometimes with std not being found. When I restart my computer, this goes away. Wish I knew why.

EDIT: This problem came back and now I can't make it go away!! Anyone know how to fix? I am sure it is something with project/compiler settings.

Philip Dodson
  • 337
  • 3
  • 9