1. First in the project directory create two profiles, a tasks.json file, a file launch.json
2.launch.json file as follows
{
// use IntelliSense understanding of the relevant property.
// hover to see the existing property description.
// For more information, please visit: https://go.microsoft.com/fwlink/?linkid=830387
“version”: “0.2.0”,
“configurations”: [
{
“name”: “(gdb) Launch”,
“type”: “cppdbg”,
“request”: “launch”,
“program”: “${workspaceFolder}/debug.exe”,
“args”: [],
"StopAtEntry": false,
“cwd”: “${workspaceFolder}”,
“environment”: [],
“externalConsole”: true,
“MIMode”: “gdb”,
“miDebuggerPath”: “gdb.exe”,
“setupCommands”: [
{
“description”: “Enable pretty-printing for gdb”,
“text”: “-enable-pretty-printing”,
“ignoreFailures”: true
}
],
“preLaunchTask”: “build-debug”
}
]
}
Where the program: $ {workspaceFolder} /debug.exe program is to be called, MIMode: "gdb"
Debugging programs, where the use gdb for debugging, "preLaunchTask": "build-debug" before the commissioning task name, and here is the build-debug following tasks.json the corresponding task name. Before commissioning means that we first call the task file generated debug.exe
3.tasks.json file contents
{
“version”: “2.0.0”,
“tasks”: [
{
“label”: “build-debug”,
“type”: “shell”,
“command”: “g++”,
“problemMatcher”: [],
“args”: [
“-g”,
“main.cpp”,
"-O",
“main.exe”
]
}
]
}
Here label is the name of the task, which is the latest version vscode wording, before using taskName is defined. type: "shell" refers to the invocation. commond: "g ++" here refers to the task of calling the program, here are compiled by g ++ files generated debug.exe
The full command g ++ is:
g++ -g main.cpp -o main.exe
So we configured four parameters in args as a call to g ++ use.
Through the above configuration can debug c ++ in vscode in, but a few are in that you've configured g ++, under the premise of gdb and other environmental variables, how to configure the g ++, gdb and other environmental variables, please refer to
Reproduced in: https: //www.jianshu.com/p/2635362efe0a