Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse CDT using MinGW does not output in console

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.

like image 907
Guillaume Avatar asked Aug 09 '10 18:08

Guillaume


People also ask

How do I display output in Eclipse?

Inside Eclipse -> Click on "Window" Select "Show View" Then select "Console" If you cannot see console in the list, select "Other" and then search for "console' in new dialog at top and select "Console"

Does Eclipse support MinGW?

Installed MinGW is not available on eclipse. New path, ;C:\MinGW\mingw32\bin (C:\MinGW is chosen during MinGW installation) has been added to environment variable path. Eclipse launched properly. However, MinGW is not available on eclipse.

Does Eclipse CDT come with compiler?

Unfortunately Eclipse only provides the Integrated Development Environment (IDE) but it is missing the actual compiler. To install a compiler, please follow the instructions for your operating system.

What is Eclipse CDT builder?

A CDT project typically has two builders. The first one is the CDT builder which is responsible for compiling your code. If you are using an external build tool you are most likely using a "makefile project", in which case the CDT builder simply invokes your build tool for you.


2 Answers

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.

like image 114
ossys Avatar answered Oct 05 '22 14:10

ossys


You need to set up linker I am using MinGW.

Follow below steps.

Goto Project > Properties > C/C++ Build > Settings > Tool Settings (Tab) > MinGW C++ Linker (Option) > Add Command (g++ -static-libgcc -static-libstdc++)   (default command is only g++) 
like image 36
Dhiral Pandya Avatar answered Oct 05 '22 14:10

Dhiral Pandya