vscode在Linux下編譯調(diào)試配置
創(chuàng)建tasks.json文件,并添加如下內(nèi)容
{
? ? "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文件,添加以下內(nèi)容:
{
? ? // 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"
? ? ? ? }
? ? ]
}
后續(xù)創(chuàng)建一個(gè)main.cpp文件,一個(gè)makefile文件,點(diǎn)擊vscode上方的run即可直接開始調(diào)試