linux下配置vscode中的ros的c++调试

发布时间:2023年12月17日

第一步

在这里插入图片描述
在这里插入图片描述

这块是launch.json

{
    "version": "0.2.0",
    "configurations": [
        
        {
            "name": "g++ - 生成和调试活动文件",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/devel/lib/beginner_tutorials/talker",//要调试的可执行文件,你调试那个文件记得把talker改为相应的cpp文件名字,beginner_tutorials为功能包
            "args": [],
            "stopAtEntry": true,//设为true则调试运行时会先停在程序开始
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "builtCpp",//要与tasks.json中label的值保持一致
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}

这一块是settings.json

{
    "python.autoComplete.extraPaths": [
        "/home/edu/catkin_ws/devel/lib/python3/dist-packages",
        "/opt/ros/noetic/lib/python3/dist-packages"
    ],
    "python.analysis.extraPaths": [
        "/home/edu/catkin_ws/devel/lib/python3/dist-packages",
        "/opt/ros/noetic/lib/python3/dist-packages"
    ],
    "cmake.sourceDirectory": "/home/edu/catkin_ws/src/beginner_tutorials",
    "files.associations": {
        "*.urdf": "xml",
        "*.urdf.xacro": "xml",
        "cstdlib": "cpp"
    }
}

这里是task.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "builtCpp",
            "command": "catkin_make -DCMAKE_BUILD_TYPE=Debug",
            "args": [],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build"
        },
       
    ]
}

在这里插入图片描述

文章来源:https://blog.csdn.net/m0_58451019/article/details/134977197
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。