how to execute c program in windows command prompt when run from eclipse cdt - eclipse

I downloaded and configured eclipse cdt along with MinGW and able to compile c programs.
My question, how to start executing the program in command prompt when Run option clicked from eclipse. Currently it always executes the program in eclipse console.
Reason to have command prompt for executing c programs is to accept user inputs.
I would also like to know is there a way to accept user inputs when c program running in eclipse console.
Thanks in advance,
-Manju

I guess i am quite late but still you can try this out. You can execute c programs through Eclipse cdt by writing a batch file and calling them through a click of button or any other event handler. Just make sure you are in the correct directory before attempting to compile and execute the file.
You can find various resources online to create a batch file which can help you execute programs through the console.
On compiling the file, (if you haven't specified an output file), a.exe file will be created. To execute this file with command line inputs just type the following in cmd (as long as you are in the same directory)
a.exe "command line inputs"
where "command line inputs" are the inputs you want to provide to your program.
Hope this is helpful!

i know 8 years is very late,but maybe somone else like me see this,so my answer is :
you should use:
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
after every printf statment to be able to input data in eclipse ide console tab ,
as i understood :""The root cause of the I/O problem is that we're using Windows pipes to communicate with the underlying process. The pipes are buffered"
you can refer to this links for more informations;
http://wiki.eclipse.org/CDT/User/FAQ#Eclipse_console_does_not_show_output_on_Windows
https://bugs.eclipse.org/bugs/show_bug.cgi?id=173732

Related

Stop Eclipse Command Line Pop Ups

I am writing a small FLTK (GUI) program on windows 7 using Eclipse Kepler. My "int main()" function is not even set to receive any command line arguments, yet every time I build the program exe and run it a command line pops up being the GUI interface.
Does anyone know how to suppress this? I do not need a console display for any input or output etc. as this is all controlled via the GUI interface.
Thanks.
It has nothing to see with eclipse. It's a standard behaviour of c++ applications on Windows. Look for console on this page. You will find how to disable it.

rawr jruby creating exe

I've a very simple Ruby script, which I've used rawr to package up into a *.jar file. I can then run the *.jar file with java -jar *.jar. I would like to make my program into an executable so I did rake rawr:bundle:exe. It says that it successfully created an executable and I can see the executable it created.
What I don't understand is, when I double click the executable (or attempt to run it in the command prompt), it doesn't really do anything; it is supposed to display 'hello' and wait for me to push enter (on STDOUT) but nothing really happens. If I run the *.jar file, it displays 'hello'. How am I supposed to run the executable? I was expecting that when I double click the *.exe, that a command prompt window pop up displaying 'hello' and waiting for me to push enter...
Since the program displays to STDOUT, and doesn't have a GUI component, I think you need to run this from the command prompt. Not sure what OS your on, since you said .exe, I'm assuming windows. so you just need to run it from the command prompt instead of by double-clicking on it.
so in the same folder where you are able to succesfully execute:
java -jar *.jar
just type:
myApplication.exe
Or, if your in another location on the machine you can type:
C:\full\path\to\myApplication.exe
Otherwise, the process is just going to run in the background with no way for you to see the results.

eclipse plugin: run command in console, get stdin

I'm making an eclipse plugin where I want to run a system command, and have the output of the command go to the eclipse console. I know how to do this via http://wiki.eclipse.org/FAQ_How_do_I_write_to_the_console_from_a_plug-in%3F
The problem I don't know how to solve, is to allow interactive input from the console for this command.
In essence, I want to kick off a command which runs in the console. The user can interact with this command (via stdin). I then want my plugin code to get a callback when the command has finished (or user has manually stopped/terminated the command in the console). Getting the return code of the completed program would be nice as well.
For simplicity sake, lets use the unix 'passwd' command as the example (this is the first common cmd I could think of that both has output and prompts for input). I don't need to hide the stdin however.
For reference, the command I'm trying to call is the CakePHP bake shell.
I assume that you got yourself a MessageConsole, like in the FAQ. Then it should be possible to use messageConsole.getInputStream().read() in a loop to get your input (but I have not tested this). See also the documentation of the IOConsoleInputStream for more options.
On the other hand I'm not sure why you are creating your own plugin to do that. The standard console implementation in Eclipse does exactly what you want. You can see that by running a small Java application, where you can use that console for input and output as well.

How to execute gdb script in eclipse when it attached?

I usually run a load libraries script when I attached to a process when I using eclipse.
I what it run this script automatically after I just attached to the process. But the .gdbinit script is executed at the beginning of attaching. Thus load libraries will fail in the .gdbinit script.
Is there a "ON_ATTACHED" function to let me do that?
I found the solution in another of my questions, I can write a .gdbinit script and define a post_run command.
How to redefine a gdb built-in command and call and call the original

How to debug a tcl script which is argument to an executable?

I have a application which takes tcl script as argument. I want to debug tcl script when the application processes it.
My development environment consists of Dynamic Languages Toolkit along with Active state remote debugger -dbgp_tcldebug. I am able to debug the individual tcl scripts with this setup.
I created a tcl project in eclipse and added 'startup.tcl' and 'argumentScript.tcl' scripts and added following command to the startup script,
set ExecutableName "xyz.exe"
set returnValue [catch {eval exec $ExecutableName "argumentScript.tcl" } result]
My debugger works fine with 'startup.tcl' script. I added the breakpoint in 'argumentScript.tcl' but it is not working. How can I debug the "argumentScript.tcl" script ?
Edit: A solution without using eclipse environment is Tcl Dev Kit with remote debugging feature.
you could use tcls introspective abilities to have the script debug itself e.g. using trace
puts f "debug message" is our all!
Just dump all that you need in log file. Simple, Stupid and Robust :)