tags:

views:

41

answers:

2

I have a console-based C project in Eclipse. Is there a button I can press to launch my application in a Command Prompt window?

A: 

Not directly, but you could configure an Ant task to run it (if it doesn't require console input), or you can configure firing up a JVM under Run|External Tools.

Carl Smotricz
+1  A: 

You can run your application as an External Tool, and there's a toolbar item for that. Looks like a green circle with a white arrow, beside a red toolbox. I'm a Java developer so I don't really know the CDT, but at least in the JDT you can run any command line tool in this way. (If it's not in your toolbar, right-click the toolbar and choose Customize Perspective… then find the External Tools item under Launch, and add it.)

First, click the down-arrow beside the button and then choose External Tools Configurations…. In the dialog, select Program from the left side and then click the New button in the toolbar. You are basically creating a shortcut that will live in the toolbar. At this point you can fill out the command line details to run your application. There's a lot of goodies like setting up environment variables, requiring a build of your projects before launching, etc. When you're done, save it, and you can run it as often as you like by clicking the arrow-and-toolbox button. You can come back and edit it later too, make duplicates, etc.

If you're working with a team, or you just want to do a really nice job:

  • In the Common tab, under Save as, choose Shared File. This will create a file in your project to represent the tool shortcut that you're building. That means you can check it into your source tree, and others can use it too. These files are XML so you want to check them in as text, not binary.
  • Start your working directory with ${workspace_loc} so that anyone who checks out your project can run it without having to adjust the shortcut for their file system.
Kevin Conner
I chose C:\Windows\System32\cmd.exe as the path and now I have to pass the processed EXE as an argument. Is there a variable in the variable list that will do that?
Pieter
Hmm... You could use something like `"${workspace_loc}/your project/your executable.exe"` and then any other arguments. I don't know how go about finding out what your executable filename is, but, you could set up a variable in `Preferences` -> `Run/Debug` -> `String Substitution` and use that variable both as your argument here, and as the output path in your link step. I'm not sure how that would be done in the CDT though! Good luck.
Kevin Conner