vscode debugging c++

1. Install remote debugging plug-in: Remote Development

2. Generate two configuration files by yourself

 The launch.json file will be generated when debugging, the specific configuration of launch.json is as follows

{
    // 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 pops up the task box, select Tasks: Configure Task to generate task.json. task.json is the real compilation option.

task.json file

{
    // 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
            }
        }
    ]
}

 

Guess you like

Origin blog.csdn.net/lcalqf/article/details/107200485