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] Sat, 24 October 2009 21:22 Go to next message
PehJota  is currently offline PehJota
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 02:06]

Report message to a moderator

Re: [SOLVED] No Output in Console [message #495869 is a reply to message #493340] Fri, 06 November 2009 08:28 Go to previous messageGo to next message
ADLR  is currently offline ADLR
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 08:28]

Report message to a moderator

Re: [SOLVED] No Output in Console [message #499461 is a reply to message #495869] Sun, 22 November 2009 14:34 Go to previous messageGo to next message
tobiokanobi  is currently offline tobiokanobi
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 08:46 Go to previous messageGo to next message
Ag-James is currently offline Ag-James
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] Sun, 27 December 2009 19:30 Go to previous messageGo to next message
PehJota  is currently offline PehJota
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 19:00 Go to previous messageGo to next message
William Cornejo is currently offline William Cornejo
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 03:23 Go to previous messageGo to next message
Axel Mueller is currently offline Axel Mueller
Messages: 1949
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 13:00 Go to previous messageGo to next message
No real name is currently offline No real name
Messages: 2
Registered: May 2011
Junior Member
[nevermind]

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

Report message to a moderator

Re: [SOLVED] No Output in Console [message #676675 is a reply to message #670366] Mon, 06 June 2011 01:35 Go to previous messageGo to next message
Thang   Le is currently offline Thang Le
Messages: 6
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 02:21]

Report message to a moderator

Re: [SOLVED] No Output in Console [message #698172 is a reply to message #676675] Mon, 18 July 2011 19:29 Go to previous messageGo to next message
Andy Gianfagna is currently offline Andy Gianfagna
Messages: 1
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 14:12 Go to previous messageGo to next message
Shane  is currently offline Shane
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 14:13]

Report message to a moderator

Re: [SOLVED] No Output in Console [message #726282 is a reply to message #726179] Fri, 16 September 2011 23:28 Go to previous messageGo to next message
Eclipse User
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] Tue, 20 December 2011 23:29 Go to previous messageGo to next message
Sathya  is currently offline Sathya
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] Wed, 01 February 2012 20:39 Go to previous messageGo to next message
Sam V is currently offline Sam V
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 17:18 Go to previous messageGo to next message
Kamal Coder is currently offline Kamal Coder
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 01:16 Go to previous messageGo to next message
Iwan Kelaiah is currently offline Iwan Kelaiah
Messages: 1
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 14:58 Go to previous message
Anandaraman Vithyananthan is currently offline Anandaraman Vithyananthan
Messages: 1
Registered: July 2013
Junior Member
Worked like a Charm !!!... Thanks. Using Eclipse with Cygwin.
Previous Topic:Not able to get the inserted Entity after Query.getSingleResult(INSERT INTO..... VALUES......)
Next Topic:Eclipse- tomcat deployment
Goto Forum:
  


Current Time: Thu Aug 21 20:15:31 EDT 2014

Powered by FUDForum. Page generated in 0.02982 seconds