Search code examples
c++ceclipseideeclipse-cdt

Eclipse IDE C++ not working C++


I've downloaded and installed the latest Eclipse, and whenever I try to run a code (after a successful build), I just get a window saying "hello.exe has stopped working", or whatever the name of my program. I can't find any helpful answers online, I've tried what I've seen. I'm using Windows 8.1, Eclipse Juno (latest version), and MinGW. Any idea why?

#include <iostream>
using namespace std;

int main() {
    cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
    return 0;
}

Solution

  • Juno is not the "(latest version)", for what it's worth. Kepler, Indigo and Luna are newer. Juno should work though.

    I suggest making sure MinGW works by itself, using a command-line compile, then installing or reinstalling the Eclipse C/C++ Development Tools (CDT). MinGW needs the proper Visual C++ runtime library to link against. The standard MinGW installation should provide that or tell you what to download from MSDN. When the compiler and IDE are separate installs, it just works out better (usually) if you install the compiler first.

    Also, get a newer Eclipse. Juno is fine for Java, but the CDT is a much younger project than Eclipse over all, and showing more growth.

    Even with Luna, I had to build twice to get the thing to recognize std::cout. If you're learning C++, I suggest Code::Blocks and MinGW as a better C/C++ environment. It's free, open-source and multi-platform, like Eclipse, but began life as a C/C++ IDE. Eclipse started as a tool for enterprise Java. For Windows, C::B has a bundle that installs a recent, high-quality build of MinGW alongside that won't conflict with any other MinGW or other compilers. One install, and it just works. The feel is nearly the same on Windows and Linux (...except that the Linux repositories usually have a much older version in ready-to-run binary, so you have to rebuild from source to get a current stable version.)