Vscode with g++ compilation and debugging
compiling
Debug
Programming with Vscode is not as convenient as vs. Some things need to be configured. compiling
Compile the configuration:
Tasks – Run Tasks – Configure task –others
Generate the Tasks.json file:
{
//See https://go.microsoft.com/fwlink/? linkid=733558
/For the documentation about the Tasks.json format
"version": "2.0.0",
"Tasks": [
{
"Label": "Echo",
"type": "Shell", "
Command": "Echo Hello",
"group": {
"kind": "Build",
" IsDefault ": True
}
}
]
}
Modify "command": "Echo Hello", that is, modify the compile command
For compiling commands, please refer to the use of the g++ command.
such as "command": "g++-g-o a.out main.cpp" Debug
Press F5 to select the gdb C + +
Generate the Launch.json file:
{//Use IntelliSense to learn about related properties.
Hover to view the description of an existing property.
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": "
Enter program name, for example ${workspacefolder}/a.out "," args ": []," stopatentry ": false, "CWD": "${workspacefolder}", "Environment": [], "externalconsole": true, "mimod E ":" GdB "," setupcommands ": [{" description ":" Enable pretty-printing for
GdB "," text ":"-enable-pretty-printing "," Ignorefailures ": true} ]
}
]
}
Modify:
"Program": "Enter program name, for example ${workspacefolder}/a.out"
For:
"Program": "${workspacefolder}/a.out"
Note: Only the command-line compiler parameter has-G to debug.
Press F5 again to do it: