zoukankan      html  css  js  c++  java
  • ubuntu+vscode+C++ debug

    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"
            }
        ]
    }
  • 相关阅读:
    工厂模式
    将博客搬至CSDN
    网络安全-跨站脚本攻击XSS(Cross-Site Scripting)
    Linux 权限
    git常用的语句
    git代码提交与克隆
    git学习
    Mybatis常见问题
    关于集合常见的问题
    远程连接(加密验证问题解决)
  • 原文地址:https://www.cnblogs.com/yrm1160029237/p/12627625.html
Copyright © 2011-2022 走看看