Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » How to run automatically compiled .exe in external console (cmd.exe)
How to run automatically compiled .exe in external console (cmd.exe) [message #1517699] Fri, 19 December 2014 17:44 Go to next message
Al Go is currently offline Al GoFriend
Messages: 4
Registered: December 2014
Junior Member
Is there a way to run compiled program inside Eclipse on Windows, but not in Eclipse internal terminal, but rather in new cmd.exe window? Some Run configuration or External Tools configuration?
Just like in QT, when you run compiled console application.
icon12.gif  Re: How to run automatically compiled .exe in external console (cmd.exe) [message #1521250 is a reply to message #1517699] Sun, 21 December 2014 18:05 Go to previous messageGo to next message
Klaus km is currently offline Klaus kmFriend
Messages: 142
Registered: November 2011
Senior Member
Quote:
Some Run configuration or External Tools configuration?


Yes, edit the Run Configuration:

On the Main page set C/C++ Application to:
${system_path:cmd.exe}


On the Arguments page add (adjust path and program name):
/C "start .\Debug\hello.exe"


On the Common page untick "Allocate console".


In the example above the console windows will close immediately if hello.exe ends. If you don't want that, use this version on the Arguments page:

/C "start ${system_path:cmd.exe} /K .\Debug\hello.exe"


Btw, you could use the same concept for External Tools configuration also!

regards,
Klaus


Re: How to run automatically compiled .exe in external console (cmd.exe) [message #1522564 is a reply to message #1521250] Mon, 22 December 2014 11:44 Go to previous messageGo to next message
Al Go is currently offline Al GoFriend
Messages: 4
Registered: December 2014
Junior Member
Thanks a lot, that what I did want.
By the way, where can I find description of Arguments (/C, /K.. etc.)?
Re: How to run automatically compiled .exe in external console (cmd.exe) [message #1522579 is a reply to message #1522564] Mon, 22 December 2014 11:54 Go to previous messageGo to next message
Joost Kraaijeveld is currently offline Joost KraaijeveldFriend
Messages: 223
Registered: July 2009
Senior Member
On 22-12-14 12:44, Al Go wrote:
> Thanks a lot, that what I did want.
> By the way, where can I find description of Arguments (/C, /K.. etc.)?

http://technet.microsoft.com/en-us/library/6ec588db-31a9-4a73-a970-65a2c6f4abbe
Re: How to run automatically compiled .exe in external console (cmd.exe) [message #1522611 is a reply to message #1522579] Mon, 22 December 2014 12:20 Go to previous messageGo to next message
Al Go is currently offline Al GoFriend
Messages: 4
Registered: December 2014
Junior Member
>Joost Kraaijeveld, Klaus Mr

Thanks again, it is very useful.
But I have one minor issue with the described above method.
My program during execution should load external image file from the same catalog where .exe file is, let say "img.png".
When I run program manually, everything goes ok.
But when I run it with the described above method via "External Tool Configuration", the program is unable to load this file and I get error message:
"Failed to load image "img.png". Reason: Unable to open file"
I suppose this is due to run cmd.exe not from the catalog where .exe file is.
Is it possible to fix it somehow, to be possible to load the file when run the program from inside Eclipse?

Re: How to run automatically compiled .exe in external console (cmd.exe) [message #1523006 is a reply to message #1522611] Mon, 22 December 2014 17:28 Go to previous message
Klaus km is currently offline Klaus kmFriend
Messages: 142
Registered: November 2011
Senior Member
Quote:
But I have one minor issue with the described above method.


Do you now what a working directory is? No? Then please read:
http://en.wikipedia.org/wiki/Working_directory

Then check the Arguments page carefully and change the setting suitable for your needs.

Quote:
But when I run it with the described above method via "External Tool Configuration", the program is unable to load this file and I get error message:
"Failed to load image "img.png". Reason: Unable to open file"

This is bad coding style, the program should catch errors.

Smile

regards,
Klaus



Previous Topic:GUI designer/wizard integrated with eclipse
Next Topic:Customizing makefile via environment variable
Goto Forum:
  


Current Time: Sat Jun 24 12:27:35 GMT 2017

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

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