'How to write a launch.json file to debug a C-Program with Visual Studio Code?
I know that Visual Studio Code in most cases, generates a launch.json file automatically for you when you hit "Run and Debug". However, this behavior does not occur when a C-Program is the target output.
I read the documentation at https://code.visualstudio.com/docs/cpp/launch-json-reference. However, they only expose how to write a launch.json file for a C++ program.
Inside my .vscode folder I have the following files:
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "gcc: launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/binaries/program",
"args": [],
"cwd": "${workspaceFolder}",
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"preLaunchTask": "gcc: build"
}
]
}
tasks.json:
{
"tasks": [
{
"type": "cppbuild",
"label": "gcc: build",
"command": "/usr/bin/gcc",
"args": [
"-g", "-o", "${workspaceFolder}/binaries/program",
"${workspaceFolder}/main.c",
],
}
],
"version": "2.0.0"
}
When I hit "Run and Debug", I get the following error:
"Unable to start debugging. The value of miDebuggerPath is invalid"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
