一、安装vsode
这个去官网下载即可,下载完后安装相应的插件
二、本地安装
sudo apt-get install gcc g++ gdb
运行命令即可,运行前先把源换成国内镜像,否则会有点慢
三、launch.json和task.json文件
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}.out",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"preLaunchTask": "build",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
task.json
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "g++",
"args": ["-g", "${file}", "-std=c++11", "-o", "${fileDirname}/${fileBasenameNoExtension}.out"]
}
]
}
即可在当前路径下,生成.out文件并运行终端。
如下所示: