在Eclipse CDT中运行可执行文件时,如何将工作目录设置为与可执行文件相同? [英] How to set the working directory when running an executable in Eclipse CDT to be the same as the executable?
问题描述
我有几个针对不同配置的构建目录(使用CLI的外部构建系统),因此可执行文件名称重复了所需的cwd:
I have several build dirs for different configurations (using an external build system from the CLI), so the executable name duplicates the desired cwd:
-
path / to / build1 /可执行文件
-
path / to / build1
(所需的cwd) -
path / to / build2 / executable
-
path / to / build2
(所需的cwd)
path/to/build1/executable
path/to/build1
(desired cwd)path/to/build2/executable
path/to/build2
(desired cwd)
是否有更方便的方法
最可能的解决方案是使用变量,例如 $ {workspace_loc}。
在参数->工作目录下,但是我找不到合适的变量。
The most likely solution would be with a variable like ${workspace_loc}
under "Arguments -> Working directory", but I could not find a suitable variable.
在Eclipse 4.6.3上进行了测试。
Tested on Eclipse 4.6.3.
推荐答案
如果您使用托管版本,则可以通过在工作区_loc后面附加config_name来解决问题,即,如果您的项目名为 test,则应该可以(在Linux上测试)
If you use managed build you can get away with specifying config_name appended to workspace_loc, i.e. if you project is called "test" this should work (tested on linux)
$ {wo rkspace_loc:test} / $ {config_name:test}
${workspace_loc:test}/${config_name:test}
我的应用打印
当前工作目录:/ home / elaskavaia / workspace / test / Debug
My app prints Current working dir: /home/elaskavaia/workspace/test/Debug
这篇关于在Eclipse CDT中运行可执行文件时,如何将工作目录设置为与可执行文件相同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!