'Set working directory for visual studio code for C++ project
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",
}
]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|