ubuntu vscode c++配置

launch.json

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/a.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "hello",
            "type": "shell",
            "command": "g++",
            "isShellCommand": true,
            "args": [
                "-g",
                "${workspaceFolder}/hello.cpp"
            ], //这边改成自己的工作目录。直接复制launch.json文件中即可
            //hello.cpp 是自己工作文件名字(一定要放在文件家夹中)
            "showOutput": "always"
        }
    ]
}

这两个文件均可以用模板生成

图片: ubuntu vscode c++配置ubuntu vscode c++配置