为C++设置Visual Studio代码的工作目录项目
我在Visual Studio代码中有一个C ++项目,并且正在尝试设置工作目录,以便我可以执行“ Assets/model.obj”以访问模型,而不必传递整个c:/users/.. 。
路径。经过一些研究,我发现您需要在启动下进行以下操作。
"configurations": [{"currentDir": "${workspaceRoot}/"}],
"program": "${file}",
"cwd": "${fileDirname}"
但是,这似乎对我不起作用。我如何为C ++项目设置工作目录?
基于建议的更新配置(仅在按DEBUG模式下工作时,按F5和当前文件为Main.CPP)
"configurations": [
{
"name": "(Windows) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/build/Debug/App.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"console": "externalTerminal",
}
]
I have a C++ project in Visual Studio Code and I am trying to set the working directory so I can do "Assets/model.obj" to access a model instead of having to pass the entire C:/users/...
path. After some research I have found that you need to do the following inside launch.json
"configurations": [{"currentDir": "${workspaceRoot}/"}],
"program": "${file}",
"cwd": "${fileDirname}"
However, this does not seem to work for me. How might I set the working directory for my C++ project?
Updated configuration based on suggestions (Working only in Debug mode when pressing F5 and current file is main.cpp)
"configurations": [
{
"name": "(Windows) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/build/Debug/App.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"console": "externalTerminal",
}
]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
如提到的评论中:
在启动中“ cwd”中的路径与“程序”中所述的配置相同。喜欢:
]
然后将您的资产复制到构建/调试 - 文件夹。您可以进行调试。
As in the comments mentioned:
put the same path in "cwd" in launch.json under configuration as stated in "program". Like:
]
Then copy your Assets to the build/Debug - folder. And you can run Debugging.