15

I'm running the latest version of Eclipse with CDT on Windows 64 bits with Cygwin for compiling the code.

My problem is that when i run any c++ software in eclipse, there is no output in the console.

I have tried this:

Eclipse CDT debugger does not show console

and this:

Eclipse CDT Debug console not displaying program output

But it does not works.

Community
  • 1
  • 1
Phil
  • 3,375
  • 3
  • 30
  • 46
  • 1
    What do you believe the program should write to the console and why? – johnsyweb Nov 11 '11 at 20:23
  • My program is just a simple Hello World file. Here it is: #include using namespace std; int main() { cout << "Hello there!" << endl; return 0; } – Phil Nov 11 '11 at 20:28

9 Answers9

19

As guys at "No Console Output (MinGW, CDT)" point out, this is probably (or at least sometimes) because Eclipse does not add PATH to MINGW\bin when launching the executable, so:

In the "Environment" tag, press "New", set it as:

  • "Name:PATH"
  • "Value:C:\MinGW\bin"

;)

mlvljr
  • 4,066
  • 8
  • 44
  • 61
  • @Phil Thanks, that's touching (I just had a similair problem and googled through this page to that one...) ;) – mlvljr Mar 27 '12 at 21:23
  • 3
    For those who don't know, On Eclipse 3.7.2 and CDT 8.0.2 the preferences for environment variables can be found in Eclipse at: `Window > Preferences > C/C++ > Build > Environment` – Sheharyar May 17 '13 at 13:39
10

Another solution that works (other than mlvljr's) is by adding the -static flag in:

Project > Properties > C/C++ Build > Settings > Tool Settings > MinGW C++ Linker > Miscellaneous > Linker Flags

Community
  • 1
  • 1
Sheharyar
  • 73,588
  • 21
  • 168
  • 215
3

Project > Properties > C/C++ Build > Settings > Tool Settings > MinGW C++ Linker > Miscellaneous > Linker Flags (add -static)

Shashank Saxena
  • 2,014
  • 17
  • 11
3

If All above is not working then You can try this

You have to add Environment variable of this project to have the path of MinGW compiler

Goto Project->Properties->Run/Debug Settings, choose the .exe file and press Edit In the Environment tag, press New, and set it as: Name: PATH Value: C:\MinGW\bin

If you are using cygwin then Value: c:\cygwin\bin

Singhak
  • 8,508
  • 2
  • 31
  • 34
1

Make sure the console is allocated:

project properties --> Run/Debug Settings --> yours.exe --> edit --> Common --> Check 'Allocate Console'

Tom
  • 539
  • 4
  • 7
  • Is there any output to the console during the build process? – Tom Nov 11 '11 at 20:46
  • Yes. I have found the problem. I have updated eclipse and now it works :-) Thanks for your suggestions. – Phil Nov 11 '11 at 21:58
1

Thanks for the answers. I have found the problem. It was a bug from Eclipse.

I went in the Help > Check For Updates.

I installed an update and now it works!

Phil
  • 3,375
  • 3
  • 30
  • 46
0

I faced this issue not long ago. Follow this link which provides quite a detailed tutorial on how to setup everything. However, the console on Eclipse Mars CDT still did not show anything. After running the generated executable file from the command line i faced the following error:

Apparently some path was missing

So considering the missing path I searched for it on cygwin main folder and added to the Project Properties -> C/C++ General -> Paths and Symbols -> Includes GNU C++ the path to the missing dll folder: ${CYGWIN_HOME}/usr/i686-pc-cygwin/sys-root/usr/bin. Run again the project, and the problem was solved:

enter image description here

I hope this will help somebody!

eldjon
  • 2,800
  • 2
  • 20
  • 23
0

As Singhak answered, this issue can be "fixed" on a project-by-project basis by adding a PATH environment variable to the project's Launch configuration: Project > Properties > Run/Debug Settings > (select the project executable) > Edit.. > Environment > New... (Name: PATH, Value: path/to/compiler/bin). But you'll have to do that for every project - I don't think there's a way to set it up to work for every project, at least I have not been able to.

However, if you're running Windows and have MS Visual Studio installed, you can set the project up using Microsoft Visual C++ Toolchains instead of GCC and that should work as expected every time.

Community
  • 1
  • 1
0

I think this night be connected to the order in which I installed MinGW and eclipse CDT (Helios). The solution (for me) was to go Project -> Properties -> C/C++ Build -> Settings -> Tool Settings -> MinGW C++ Linker -> Miscellaneous -> and set Linker flags to -static-libgcc -static-libstdc++. But I seem to need to do this for every project so I'm still searching for a permanent fix.

Clarius
  • 1,183
  • 10
  • 10