vscode 调试c++

1、安装远程调试插件:Remote Development

2、自己生成两个配置文件

 debug时会生成launch.json 文件,  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": "clang++ - Build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            //此处和下面task中的label值相等    
            "preLaunchTask": "C/C++: clang++ build active file",
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}

command+shift+p 弹出任务框,选择Tasks:Configure Task,生成task.json。task.json才是真正编译选项。

task.json文件

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "0.2.0",
    "tasks": [
        {
            "label": "C/C++: clang++ build active file",
            "type": "shell",
            "command": "g++",
            "args": [
                "-g",
                "-std=c++11",
                "-L/data1/out/ffmpeg/lib",
                "-I/data1/out/ffmpeg/include",
                "-lavcodec",
                "-lavdevice",
                "-lavfilter",
                "-lavformat",
                "-lavutil",
                "-lpostproc",
                "-lswresample",
                "-o",
                "${fileBasenameNoExtension}",
                "${file}"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

猜你喜欢

转载自blog.csdn.net/lcalqf/article/details/107200485