Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » [SOLVED] No Output in Console(Only Displays "<terminated>")
[SOLVED] No Output in Console [message #493340] Sun, 25 October 2009 01:22 Go to next message
PehJota  is currently offline PehJota Friend
Messages: 3
Registered: October 2009
Junior Member
I'm using Eclipse Galileo on Windows with MinGW. I'm trying to build and run a simple C++ program. It builds fine, and I can run the program from cmd with no problems. But if I try to run the program in Eclipse, I get nothing in the Console view. It says "<terminated>" though. In my web searching I've seen others experiencing this same problem, but unfortunately I haven't seen any solution.

This is the sample program I'm trying to run (just output, nothing complicated):

#include <cstdio>


int main(int argc, char* argv[]) {
	
	printf("Hello.\n");
	fflush(stdout);
	
	return 0;
	
}


Anyone know how to fix this?

EDIT:

Ah, I figured out the problem. Adding the linker flag "-static-libgcc" will fix at least the following three issues that I know of: programs built with MinGW don't work on machines that don't have MinGW installed; programs don't run in the Eclipse Console; and gdb fails when the program starts.

For anyone who may need to know:
To add this flag in Eclipse, go to Project->Properties. Under "C++ Build", select "Settings". Under "MinGW C++ Linker", select "Miscellaneous". Add "-static-libgcc" to the "Linker flags" field. You may have to do this for your other build configurations and projects.

[Updated on: Sun, 25 October 2009 06:06]

Report message to a moderator

Re: [SOLVED] No Output in Console [message #495869 is a reply to message #493340] Fri, 06 November 2009 13:28 Go to previous messageGo to next message
ADLR  is currently offline ADLR Friend
Messages: 2
Registered: November 2009
Junior Member
Actually I do have the same problem, but I cannot solve it with your solution. Maybe you have an idea what I could do, to do this for plain C.

I do get my console output after the programm has already ended, so I cannot give any input to the tool. Everthing works in cmd.exe, but not in the eclipse console view. Crying or Very Sad

[Updated on: Fri, 06 November 2009 13:28]

Report message to a moderator

Re: [SOLVED] No Output in Console [message #499461 is a reply to message #495869] Sun, 22 November 2009 19:34 Go to previous messageGo to next message
tobiokanobi  is currently offline tobiokanobi Friend
Messages: 1
Registered: November 2009
Junior Member
I'm pushing this topic, since I do have the same issue. Program runs fine from cmd on a windows XP stem build with mingw and eclipse CDT (Galileo). But I don't get any output to the eclipse console, except when I hit the red "terminate" square.

I haven't tried fflush yet, but it should work without it or? And yes, I've set the run configuration as described in the manuals.

And as it looks like, I'm not the only one.

Best regards,

Tobias
Re: [SOLVED] No Output in Console [message #505090 is a reply to message #499461] Sat, 26 December 2009 13:46 Go to previous messageGo to next message
Ag-James is currently offline Ag-JamesFriend
Messages: 2
Registered: December 2009
Junior Member
I would like to put topic forward once again. I am unable to see an output within an eclipse console for C program.

I am using Windows 7_64 bit with Cygwin on top.
From cmd.exe everything works fine.

I have tried almost every workaround that I have found in the net, however none of them helped to solve the problem.

If anyone by any chance know how to overcome this issue for C, please help.

Thanks!
James
Re: [SOLVED] No Output in Console [message #505150 is a reply to message #493340] Mon, 28 December 2009 00:30 Go to previous messageGo to next message
PehJota  is currently offline PehJota Friend
Messages: 3
Registered: October 2009
Junior Member
Yes, you do need to include calls to fflush to flush the stdout buffer. I think this is because the cstdio library treats the Eclipse Console as a file stream, and output is not implicitly flushed as often as with a standard terminal (like cmd.exe). I think it's good practice to explicitly flush the output buffer anyway, just to be sure it's printed in all possible environments.

If you get console output after the program has ended, then that sounds to me like the output buffer isn't being flushed. As I said, using "fflush(stdout);" and adding "-static-libgcc" to the linker flags (if you're using MinGW/GCC, other compilers probably have some other flags to statically link their runtime libraries) seems to make it work, at least for me.
Re: [SOLVED] No Output in Console [message #669328 is a reply to message #505090] Mon, 09 May 2011 23:00 Go to previous messageGo to next message
William Cornejo is currently offline William CornejoFriend
Messages: 1
Registered: July 2009
Junior Member
I have exactly the same issue.

System is Win Pro x64 with Eclipse Helios CDT and Cygwin.

With Windows XP in the same machine, same configuration everything was ok, now with x64 issue arises.

Running the program from console or by using debugging in Eclipse shows the output.

Regards,
Re: [SOLVED] No Output in Console [message #669682 is a reply to message #669328] Wed, 11 May 2011 07:23 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
There were some postings in this forum about problems with x64 on Windows. I do not remember if this problem as resolved or a workaround exists. You should do a search on this forum.

Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: [SOLVED] No Output in Console [message #670366 is a reply to message #669682] Fri, 13 May 2011 17:00 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 2
Registered: May 2011
Junior Member
[nevermind]

[Updated on: Fri, 13 May 2011 17:01]

Report message to a moderator

Re: [SOLVED] No Output in Console [message #676675 is a reply to message #670366] Mon, 06 June 2011 05:35 Go to previous messageGo to next message
Thang   Le is currently offline Thang LeFriend
Messages: 10
Registered: May 2010
Location: Vietnam
Junior Member
i got the same problem: cannot display to eclipse console even though i added "-static-libgcc" to the linker flags. i am using win7 64 bit, eclipse helios, CDT 7.0.2, MinGW 5

-------------
i downgrated to CDT 7.0.0 too but was still not resolve the problem

thanks

[Updated on: Mon, 06 June 2011 06:21]

Report message to a moderator

Re: [SOLVED] No Output in Console [message #698172 is a reply to message #676675] Mon, 18 July 2011 23:29 Go to previous messageGo to next message
Andy Gianfagna is currently offline Andy GianfagnaFriend
Messages: 2
Registered: July 2009
Junior Member
I was getting the same behavior on Win 7 64 Bit. Adding the -static-libgcc helped get things to show up in the debugger view, but they still didn't show when running in C++ view. However when I added a PATH variable set to C:\MinGW\bin in the Run Configuration, then I saw stdout when running from a normal run configuration in the C+ view. HTH.
Re: [SOLVED] No Output in Console [message #726179 is a reply to message #698172] Fri, 16 September 2011 18:12 Go to previous messageGo to next message
Shane  is currently offline Shane Friend
Messages: 1
Registered: September 2011
Junior Member
Quote:
I added a PATH variable set to C:\MinGW\bin in the Run Configuration


Tyvm for this solution. My console now has output Very Happy

[Updated on: Fri, 16 September 2011 18:13]

Report message to a moderator

Re: [SOLVED] No Output in Console [message #726282 is a reply to message #726179] Sat, 17 September 2011 03:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Jarrick Chagma

"Shane" wrote in message news:j502st$gfn$1@news.eclipse.org...

>Tyvm for this solution. My console now has output :d

Yes, and mine too now. But why is this necessary? I am using Eclipse 3.7
but this wasn't necessary with Eclipse 3.6.2.

--
Regards,

Jarrick
icon14.gif  Re: [SOLVED] No Output in Console [message #768931 is a reply to message #698172] Wed, 21 December 2011 04:29 Go to previous messageGo to next message
Sathya  is currently offline Sathya Friend
Messages: 1
Registered: December 2011
Junior Member
Thanks solved my problem

Thanks,
Sathya
Re: [SOLVED] No Output in Console [message #788601 is a reply to message #768931] Thu, 02 February 2012 01:39 Go to previous messageGo to next message
Sam V is currently offline Sam VFriend
Messages: 1
Registered: February 2012
Junior Member
Thank you for posting about the path setting. This did it for me as well. - SamV
Re: [SOLVED] No Output in Console [message #817928 is a reply to message #493340] Sat, 10 March 2012 22:18 Go to previous messageGo to next message
Kamal Coder is currently offline Kamal CoderFriend
Messages: 1
Registered: March 2012
Junior Member
It helped me too!
Re: [SOLVED] No Output in Console [message #1015529 is a reply to message #726179] Fri, 01 March 2013 06:16 Go to previous messageGo to next message
Iwan Kelaiah is currently offline Iwan KelaiahFriend
Messages: 6
Registered: March 2013
Junior Member
This solved my problem with Juno and CDT. The year is 2013.

But I already set PATH to my MinGW in Window -> Preferences -> Build -> Environment! why do I need to do this also to see output in Console?
Re: [SOLVED] No Output in Console [message #1067227 is a reply to message #493340] Sun, 07 July 2013 18:58 Go to previous messageGo to next message
Anandaraman Vithyananthan is currently offline Anandaraman VithyananthanFriend
Messages: 1
Registered: July 2013
Junior Member
Worked like a Charm !!!... Thanks. Using Eclipse with Cygwin.
Re: [SOLVED] No Output in Console [message #1573641 is a reply to message #1015529] Mon, 19 January 2015 21:37 Go to previous messageGo to next message
Andreas Martin is currently offline Andreas MartinFriend
Messages: 1
Registered: January 2015
Junior Member
Windows 7 x64; Eclipse Juno 64 bit; MinGW-W64; year 2015!

The good news; the Solution still works, but... this means the "feature" is still there, too. What the hack...

As mentioned above the path is supposed to be set already under project\properties\C/C++ Build\Environment\Path so where is the difference?

Does anybody have an explanation for this behavior? Thanks in advance.
Re: [SOLVED] No Output in Console [message #1794179 is a reply to message #1573641] Sun, 26 August 2018 07:27 Go to previous message
Embedkari system is currently offline Embedkari systemFriend
Messages: 1
Registered: August 2018
Junior Member
Hi All, I am not sure whether this is really resolved . As per my understanding redirecting console to external helps to see print output in real time. I have tried to explain it in youtube, Just search for embedkari
Let me know if it helps. Have a Great time
Previous Topic:Building from CLI works but not from IDE itself
Next Topic:Unable to debug with Neon and TDM-GCC
Goto Forum:
  


Current Time: Fri Mar 29 05:11:25 GMT 2024

Powered by FUDForum. Page generated in 0.03427 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top