Is it possible to start an external program from the target directory when debugging?

我们两清 提交于 2020-01-03 19:40:05

问题


When debugging I need to start an external program from the target directory of a build and am wondering if it can be accomplished using relative paths.

As a post-build event I have the following:

IF NOT "$(ConfigurationName)"=="Debug" GOTO End
:CopyExecutable
copy "$(SolutionDir)\Source\Lib\MyExecutable.exe" "$(TargetDir)"
:End

I need to run MyExecutable.exe when I am debugging so in the debug tab for the project properties I set "Start external program" to MyExecutable.exe but get a failure when running the debug. It seems I need to put the full path for this to work.

Is there a way to do this using relative paths?


回答1:


The 'Start External Program' path is relative to your solution directory (in VS2005 anyway). So you could just put:

Source\Lib\MyExecutable.exe

I see you asked this a while ago, but I just ran into the same problem, and this is how I solved it.




回答2:


(_Disclaimer: all directions are based on VS08. Things may be in different places in prior or future versions)

I get the feeling that your other program is not a post-build step you need to run before debugging, but rather a program that also needs to run (a server or something) aswell while you debug.

Use an empty C++ Make-File project (you can use other project types, but this one by default does no actual building, so I find it's the easiest), and alter its start-up properties (Project/Properties -> Debug) to run your other application. Then, set your solution to start multiple projects (Solution/Properties -> Common Properties -> Startup Project).




回答3:


Did you try something like $(TargetDir)\..\Lib ?



来源:https://stackoverflow.com/questions/334373/is-it-possible-to-start-an-external-program-from-the-target-directory-when-debug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!