加入收藏 | 设为首页 | 会员中心 | 我要投稿 好传媒网 (https://www.haochuanmei.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

Linux上使用vscode编译运行和调试C/C++

发布时间:2022-11-16 16:31:25 所属栏目:Linux 来源:网络
导读: tasks.json 指定编译文件
launch.json 使用gdb调试
ctrl+shift+p
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "default",
"type":

tasks.json 指定编译文件

launch.json 使用gdb调试

ctrl+shift+p

tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "default",
            "type": "shell",
            "command": "g++",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}", //importance
            ],
            "problemMatcher": {
                "owner": "cpp",
                "fileLocation": [
                    "relative",
                    "${workspaceRoot}"
                ],
                "pattern": {
                    "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                }
            },
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

launch.json

{
 "version": "0.2.0",
 "configurations": [
        {
 "name": "(gdb) Launch",
 "type": "cppdbg",
 "request": "launch",
 "program": "${fileDirname}/${fileBasenameNoExtension}",//importance
 "args": [],
 "stopAtEntry": false,
 "cwd": "${workspaceFolder}",
 "environment": [],
 "externalConsole": false,
 "MIMode": "gdb",
 "preLaunchTask": "default", // must specify task name(label in tasks.json)
 "setupCommands": [
                {
 "description": "Enable pretty-printing for gdb",
 "text": "-enable-pretty-printing",
 "ignoreFailures": true
                }
            ]
        }
    ]
}

可参考具体配置 zhuanlan.zhihu.com/p/80659895

万字长文把 VSCode 打造成 C++ 开发利器 - 腾讯技术工程的文章 : zhuanlan.zhihulinux编译器.com/p/96819625

(编辑:好传媒网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!