vscode在Linux下编译调试配置
创建tasks.json文件,并添加如下内容
{
"tasks": [
{
"type": "cppbuild",
"label": "build",
"command": "make",
// "command": "/usr/bin/g++",
"args": [
// "-fdiagnostics-color=always",
// "-g",
// "${file}",
// "-o",
// "${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
添加launch.json文件,添加以下内容:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/sshterminal",
"args": [
"ubuntu",
"192.168.20.145",
"ubuntu",
"22"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
],
"preLaunchTask": "build",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
后续创建一个main.cpp文件,一个makefile文件,点击vscode上方的run即可直接开始调试