C++ Eclipse: stdin in different console than stdout - c++

I encountered a strange of Eclipse on Linux.
I have a simple C++ console program that prints some messages to stdout (cout) which is displayed in a console named "Default [C/C++ Application] ApplicationName" where "ApplicationName" is the name of my executable.
When I try to read a character with getchar() this console does not react to any input.
I have to switch the console to another console named: "Default [C/C++ Application] gdb" where I can enter a message which is then read by getchar().
So it looks like stdin and stdout is routed to different consoles during debug. If running the App without debugger from a Console Window outside of Eclipse everything works fine.
How can I make Eclipse use the same console for input and output.
I now installed the latest version of Eclipse Keppler and the problem still exists.

I am using ubuntu 12 and eclipse kepler and program it using same console for input and output. I have tested it with and without GDB.
Eclipse IDE for C/C++ Developers
Version: Kepler Service Release 1
Build id: 20130919-0819

Mine is Indigo on Linux Mint. It was the version that I got when istalled from the "App-Store".
Will try to install the new Version. Thanks.

Related

CLion run program in separate system terminal

I have an ncurses program that I'd like to interactively debug using CLion. The problem is that when I run the program in CLion to debug it, the inbuilt console where the program is run doesn't display the output of the ncurses program properly.
I'd like to have the program run in my systems terminal so I can see the output properly whilst debugging the program with CLions debugger.
Is there any way to do this?
The best way to accomplish this is to use GDB now it can be really frustrating to get started so Ill show you how I accomplished it in linux
open a terminal and go to your project debug file and type gdbserver localhost:1234 ./myFile
open clion to myFile project and in the upper right corner you should see a build all (or your projects name) click it and go to "edit configurations"
in the upper left corner you should see a plus sign, click it and press "GDB remote debug"
then in "target remote" type tcp:127.0.0.1:1234
Next in "path mappings" press the plus and type /location/to/file/myFile (same file as in 1.) in both Remote and Location
Press OK and in the upper right corner select the name of the configuration that you just made and press debug
you might need to try to restart the gdbserver one more time for this to work but if you did all the steps above you should see a debug prompt come up and on the terminal you should see your project running.
There are some limitations with this for example you always have to run gdbserver localhost:1234 ./myFile command on your terminal for it to work.
Some Video/documentation that helped me:
Debugging with GDB at 33:35 (Video by JetBrain)
GDB documentation on Jetbrain
I hope this helped :)
In other debuggers, you would do this by running the ncurses application in a terminal, and attaching the debugger to the process using ncurses.
Doing that avoids interference between ncurses (which changes the terminal I/O modes) and the debugger's command-line.
The attach feature is a recently released feature of the CLions debugger:
Further reading:
More power to debug: Attach to local process (January 20, 2016)
CLion 1.2 roadmap (August 31, 2015)
Debugging in CLion (May 8, 2015 )
CLion answers frequently asked questions (September 16, 2014)
Debugging ncurses application with gdb
Using GNU's GDB Debugger:
Debugging Ncurses Programs

Unable to run SDL program in Eclipse but able to do so in Windows Explorer

I have installed and set up SDL and managed to get a tutorial example to build (the tutorial code is from http://zamma.co.uk/setup-sdl2-eclipse-windows/) as a C++ Project in Eclipse.
The problem is that when I try to run the application from Eclipse, the window doesn't appear, or perhaps it gets closed soon after appearing. Eclipse doesn't appear to show any errors.
When I open the folder containing the executable in Windows Explorer and double-click on the application, it works; a window appears with "Hello World" as the title and closes after two seconds.
How can I get the window to appear when I run from Eclipse? Any breakpoints I set are ignored by the debugger.
IDE: Eclipse Luna 4.4.1 OS: Windows 7 64-bit
The program now runs in Eclipse, so the solution may have been to refresh Eclipse and double check Build settings and Run configurations, as well as checking for any OS modifications that may affect the software running on it (thanks to all who replied for the help).

How to let terminal window be closed automatically in a linux Console Application when run by IDE

When I compile a C++ console application in a Linux IDE like Qt Creator or code::blocks, the terminal window (unlike Windows Console) waits for pressing Enter to be closed. Codes like exit(0) and system("exit") don't work.
Is there any code or option in Qt IDE to let the terminal window (xterm or konsole) be closed automatically after execution.
It is actually made for you. If you build executable of your application and run it from terminal (outside of IDE), it (your application... not the terminal) will close after execution (return in main).
CodeBlocks uses smth called cb_console_runner to run executables and wait for ENTER to close terminal. I am not sure how is it possible to make it work without cb_console_runner
EDIT: In codeBlocks... remove/rename cb_console_runner in /bin and it is solved:)
to make it easier: run this command:
sudo mv /bin/cb_console_runner cb_console_runner_s
In QtCreator in Project->Run settings
uncheck "Run in Terminal"

Debugging ncurses with Eclipse CDT

I'm writing a C++ application using ncurses in Eclipse CDT however I can't run/debug my app in eclipse because the console in eclipse does not work with curses. My app runs fine if I run it from a terminal but I just added some new code and now I'm getting a segmentation fault so I'd like to use the debugger in eclipse to help me fix the issue. Is there a way to have eclipse run/debug my application but use a different terminal for the output much like when you do "tty /dev/pts/1" in gdb? Or any other way to debug a ncures application in eclipse?
Thx in advance!
also you should add TERM=xterm to Environment in the Debug Configurations dialog

How can I output execution display to console in Eclipse for remote C++?

I'm using Eclipse 3.4.1 with Hp/UX plugin for remote debugging of C/C++. It works very fine, except for one issue: whenever I compile my projects, the output display is Eclipse's console view, but when I run or debug any projects, the output window is the old and not-so-good MS-DOS command window. I haven't find any way to change this behavior.
How do I set the execution output display to Eclipse console?
Update:
Environment: running Eclipse 3.4.1 on Windows XP and debugging C/C++ applications on an HP/UX server.
CDT version is 5.0.0.
Which version of CDT are you using? Because from this "hello world" guide it seems the spawner.dll pretty much handles this console redirection for you.