input not working while running in debug mode - eclipse cdt - eclipse

Standard input works fine when I run my program, but doesn't work when in debugging mode, although output works fine as well.
I'm running Eclipse Photon (4.8) with CDT and for my toolchain I use gcc provided by Cygwin and I use gdb as my debugger.
Output when I run the program without debugging
Output when I run the program with debugging, mind the variable watches and the console
The Cygwin toolchain is detected automatically because it is present in the PATH environment variable, I also reset the workspace, but that didn't help.
UPDATE: If I put multiple cin lines one after another, the first cin will return a number different from that in the input and every consecutive cin will return a zero as a value.
UPDATE2: I found a workaround. If you use an external console (cmd) instead of the one in Eclipse, then it works. Image

Related

Eclipse LDT doesn't run local Lua interpreter

I have problem with Eclipse LDT. When I run my test Lua app, it executes just fine using JNLua inside JavaVM environment. But according to this tutorial, when I reference native lua.exe interpreter and set it in Run Configuration as Runtime Interpreter, Run Configuration disables Launch script: and nothing is executed. When I run a same script with a same native local Lua interpreter 5.1, everything works just fine.
So, what is the problem with LDT? Has anyone had the same experience?
EDIT
I've managed to run local lua.exe from Lua Development Tools stand-alone product, but still it doesn't work as Eclipse plug-in.
I'm not sure it's a bug.
I guess when you register your interpreter, you uncheck the checkbox : "Accept file as argument"
This mean LDT will not manage the file to launch (that's why the Launch script is disabled)
The standard lua interpreter support file as argument and -e option, so the two check box should be checked. (It's the default value)
It looks like a bug ... Would you mind filing it in the Koneki bug tracker?

eclipse opening X11 Window

I wanted to see how the code of FFMpeg works. So what I did is imported this project in eclipse. When I run the binary from the command line, it decodes the entire video without any problem and displays it as well. However if I run exactly same binary from the eclipse, it fails. It fails when the binary executes the following statement -
instance->display = XOpenDisplay (NULL);
Can anyone tell if there is any special requirement for running X11 apps in eclipse? I have linked the necessary libraries in the code. Also the binary works perfectly from the command line.
Had a similar problem developing with ROOT gui classes.
I solved the issue adding the env variable DISPLAY to :0 in the run configuration tab.

eclipse debug perl curses

I am writing a Perl program that uses curses for output and move the cursor, and color characters. Previously, when I was working under windows I use Komodo it was able to run an external console.
Now I work in Linux environment and use eclipse + epic. If you try to just run the script, it uses the internal console eclipse, which is very cut. You can just run the script using external tool, but I'm interested to debug using external console window. Is this possible?
Unfortunately, use of a File and /dev/pty/1 does not help in solving my problem.
The fact is that in this case it is impossible to get the characters introduced in the console through curses getch(). Always returned 1 instead code of pressed key.
Here is an answer that will take you most of the way (based on post #6 of: http://ubuntuforums.org/showthread.php?t=743131, although since then, in the "Indigo" and "Juno" versions of Eclipse, things have changed somewhat, and this answer is up to date):
Go to "Run -> Debug configurations". Click on the (fourth) "Common" tab. Go to the third frame from top, and there, check-mark the checkbox which says: "File". Enter the file name of the console window you want your output in.

Difference in Run & Debugg mode in Eclipse for Perl

I am using Eclipse along with EPIC plug in and pad walker for running my Perl project.
I am facing a strange issue
If I "Run" the project, the system fails and exits Perl without any error message.
But if I "Debug" the project and then give "Run" the same Perl scripts work fine as expected.
Could anyone let me know the difference in the two mode ("Direct Run" & "Debug & Run")?
Found it in the EPIC source code: EPIC adds the "-d" command line option for the debug target. It does some interesting things with the stdin/stdout too to remotely control the debugger. So maybe there's some side effect there? Can you share the error message?

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.
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.
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++)
purlogic's solution works.
Instead to set that for every project, I found it can be set globally:
In Window -> Preferences-> C/C++ -> Build -> Environment
Add a variable for your compiler. e.g, I added:
MINGW, with value "C:\MinGW\bin"
This console bug has been noticed in 64-bit versions of eclipse:
http://www.eclipse.org/forums/index.php?t=msg&th=197552&start=0&S=2a2b64e1f1404705c0214976bd477428
A workaround is to install the 32-bit eclipse
I ran into the same problem, because of multiple gcc installations on one PC. But Greg's solution only worked partly for me.
In my case the flush was not done in the application explicitly. While C++ programs often use std::cout << ... << std::endl where the endl does a flush, my program used actual C-output such as the usual printf. The printf could be seen directly when starting the program in the cmd-window. However in eclipse console they were missing. Hence a
fflush(stdout);
after the printf did the thing for me. That could be an issue within the eclipse console implementation. I guess that's why fixing the Path did not work for some people here.
An alternative solution instead of setting the PATH within the "Run" settings is to start the whole eclipse using a batch file, which looks essentially like this:
set PATH=<mymingwlocation>\bin;%PATH%
start <myeclipselocation>\eclipse.exe
Then any run configuration would use the correct MingW location by default. That might also fix other problems that could arise from using the wrong gcc.
Have you tried to execute the eclipse.exe with administrator privileges ?? it worked for me !
Had this issue on 64-/32-bit eclipse Kepler CDT to work on a openCV/wxWidgets tool, Win7, using MinGW to build.
If anyone comes across this while having this issue and are working with openCV you will already know that there are many outdated openCV building/installing instructions all over the internet.
One I had was to go to Build Settings -> Linker -> Miscellaneous and inside of the Linker Flags text entry box, type in
-Wl,--subsystem,windows -mwindows
However, this disables cout from outputting to a command line terminal in windows.
Doing some more digging this looks intentional, apparently the -mwindows involves directing STDOUT away from a command line specifically to a GUI-like application.
Also, removing -mwindows and just leaving in -Wl,--subsystem,windows accomplishes the task of redirecting STDOUT anyway away from the command line all the same.
Now mind you, I haven't built up anything yet outside of a hello world program involving wxWidgets and openCV, so I am not at the point of doing a cout into a part of a GUI so I don't know if that functionality would now be broken or if it would print out to the GUI object, as well as a command line terminal.
Or set the linker option -static.
Works for me at least.
Add PATH variable (PATH="your MinGW/bin directory path") into your C++ project by Run -> Run Configurations ->in Environment Tab