Search code examples
eclipseeclipse-cdt

Eclipse CDT setup problems


I am having some difficulties in setting up Eclipse CDT. I am currently running Eclipse Juno on Fedora 17. Until now I have been using this for my Android development and my workspace contains a mix of local code, CVS and GIT projects.

I installed the CDT plugin through Eclipse - no problems here. But there are some issues:

  • When I open up the C/C++ perspective it contains all my Java/Android projects.
  • I can't seem to use STL functionality

When I use the wizard to simply create a hello world Makefile / GCC project I am presented with a few lines of code using the stdio functionality. I thought I'd quickly change this to use the STL routines like so:

#include <iostream>

int main(int argc, char* argv[]) {
    std::cout << "Hello World" << std::endl;
}

But somehow it can't resolve cout and endl. If I change this to

#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
    cout << "Hello World" << endl;
}

it cannot resolve std.

Surely something simple like this should work out of the box. I have been quite happy with my editor and commandline GNU tools for over 15 years - the only reason I thought I'd give an IDE a go is because I am quite pleased with it doing Android stuff. Does Eclipse CDT need a lot of fiddling to get going?


Solution

  • 1) For your first problem I would just create new Workspace for C/C++ projects and keep my Java projects in separate workspace (unless they are a part of same product).

    2) You have probably not selected proper toolchain type. When you create C++ project -> Makefile project -> Hello, you need to select "Linux GCC" in listbox on right (Toolchains). CDT contains separate parser (for syntax coloring and early warnings) that scans for possible errors while you type, and this is not properly set up if you don't select "Linux GCC". The code should still compile, though, as it will just do a "make all". Note that with CDT you need to manually build project by default (Through project->build all or similar).