欢迎光临散文网 会员登陆 & 注册

vscode在Linux下编译调试配置

2023-08-07 17:25 作者:芯无波澜  | 我要投稿

创建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即可直接开始调试

vscode在Linux下编译调试配置的评论 (共 条)

分享到微博请遵守国家法律