Eclipse CDT using MinGW does not output in console

Guillaume picture Guillaume · Aug 9, 2010 · Viewed 47.8k times · Source

I have a Windows 7 64-bit PC and I am trying to install a free C++ IDE, so I chose to install Eclipse Helios with CDT.

For g++, make and gdb I installed msys and mingw according to this tutorial: http://wiki.wxwidgets.org/HowTo:_Install_MSYS_and_MinGW_for_use_with_Eclipse_CDT

The versions are:

  • make: GNU make 3.81
  • g++: 4.5.0
  • gdb: 7.1

So it should be compatible with my 64-bit CPU.

However when I try to run a very simple program with eclipse, I see nothing on the console. The source code is:

#include <iostream>

 using namespace std;

 int main()
 {
    int i;

    cout << "Enter an integer: " << endl;
    cin >> i;
    cout << endl << "i is " << i << endl;

    return 0;
 }

The build is fine and when I launch the .exe with command (windows console) the behavior is as expected. But with the Eclipse console I see nothing with run and with debug the output is just: "Enter an integer: ", then when I type in a number and hit enter it does nothing.

Does anyone know how to fix this please?

Thanks,

Guillaume

PS: I use the toolchain "Linux GCC", with "MinGW GCC" I have nothing at all in the console.

Answer

ossys picture ossys · May 11, 2011

This worked for me on 64-bit install of Eclipse on Windows 7 using MinGW:

Right-click on your project. Select "Properties".

Select the "Run/Debug Settings" Property on the left of the new window.

In the right window, click on your executable to highlight (ie - Test.exe) and click "Edit".

In the Environment tab, hit "New"

Name: PATH
Value: Path to your MinGW bin directory. (For me this was: C:\devcore\MinGW\bin)

Click "OK" on all windows to close down.

Try running again, it should print output to the screen.