码迷,mamicode.com
首页 > 编程语言 > 详细

ubuntu+vscode+C++ debug

时间:2020-04-03 19:51:28      阅读:71      评论:0      收藏:0      [点我收藏+]

标签:figure   ace   lan   oss   选择   x64   设置   link   vsc   

0.点击Vscode左边的debug按钮,进入debug模式,但是一开始里面没有Configuration文件。add Configuration,之后选择C++,VScode会在工作路径下自动生成一个.vscode文件夹。

1.c_cpp_properties.json

打开vscode控制台,输入C/Cpp: Edit configurations,就自动生成了一个c_cpp_properties.json文件,这样你就可以在该文件中编写参数来调整设置。

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/g++",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4
}

 

2.task.json输入Tasks: Configure Tasks

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558 
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "g++ build active file",
            "command": "/usr/bin/g++",
            "args": [
                "-g",
                "${workspaceFolder}/main.cpp",//注意修改为你的文件名
                "-o",
                "${workspaceFolder}/main"//注意修改为你定义的名字
            ],
            "options": {
                "cwd": "/usr/bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build"
        }
    ]
}

 

3.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": "g++ - Build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/main",//注意修改为和task一样的名称
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "g++ build active file",
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}

 

ubuntu+vscode+C++ debug

标签:figure   ace   lan   oss   选择   x64   设置   link   vsc   

原文地址:https://www.cnblogs.com/yrm1160029237/p/12627625.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!