Are you sure you installed the C/C++ Studio Code extension? If you don't get the popup, try writing the json files manually.
Create a .vscode
folder in your working directory. In there create a file launch.json
in which you declare how you run the debugger
{
"configurations": [
{
"name": "Debug",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}\\test.exe",
"stopAtEntry": true,
"cwd": "${workspaceRoot}",
"preLaunchTask": "Build Debug",
"miDebuggerPath": "c:\\mingw64\\bin\\gdb.exe"
}
]
}
This runs the gdb
debugger that came with MinGW. You need to provide the path to your debugger at miDebuggerPath
.
This debugs an executable test.exe
that needs to be created in debug mode. For this you have the preLaunchTask
option. In .vscode
create a file tasks.json
in which you describe the debug task as
{
"tasks": [
{
"type": "cppbuild",
"label": "Build Debug",
"command": "g++",
"args": [
"${workspaceRoot}\\test.cpp",
"-g",
"-o",
"${workspaceRoot}\\test.exe"
],
}
],
"version": "2.0.0"
}
This uses the gcc
or g++
compiler that also comes with MinGW to compile a single source file test.cpp
into the test.exe
binary. You can select the debug launch configuration in the lower left corner of Studio Code and click Run.