VSCODE配置C++ Debuger

官方更新vscode之後好用了很多,並且有了C++的插件,但是很坑爹的是官網上寫的很不清楚。

很多人寫了博客,但是配置的都比較蛋疼。
這裏寫圖片描述
(我使用的是ubuntu 其他操作系統可能類似?)

launch.json配置

你在debug裏面按f5運行的時候,就會出現讓你配置launch.json的頁面。配置文件如下:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch",
            "type": "cppdbg",
            "request": "launch",
            "targetArchitecture": "x64",
            "program": "${file}.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": true,
            "linux": {
                "MIMode": "gdb"
            },
            "osx": {
                "MIMode": "lldb"
            },
            "windows": {
                "MIMode": "gdb"
            },
            "preLaunchTask": "g++"
        },
        {
            "name": "C++ Attach",
            "type": "cppdbg",
            "request": "launch",
            "targetArchitecture": "x64",
            "program": "${file}.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "processId": "${command.pickProcess}",
            "externalConsole": false,
            "linux": {
                "MIMode": "gdb"
            },
            "osx": {
                "MIMode": "lldb"
            },
            "windows": {
                "MIMode": "gdb"
            }
        }
    ]
}

task.json配置

這時候你運行時候會出現讓你配置task.json

{
    "version": "0.1.0",
    "command": "g++",
    "isShellCommand": true,
    //"args": ["-o","${workspaceRoot}/${file}.out","${file}"],
    "args": ["-o","${file}.out","${file}"],
    "showOutput": "always"
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章