ubuntu 16.04 vs code中调试ORB-SLAM3

如果是在vs code中编译,在vs code中调试,那么执行如下,如果还是在终端中编译,只在vscode中调试,那么应该可以忽略(1-3)

注意

修改build.sh文件中最下面的DCMAKE_BUILD_TYPE为Debug,如果没改加不了断点

(1) 创建c_cpp_properties.json

ctrl + shift + P后输入C/C++: Edit configurations,其中内容可以先保持默认的不做修改。

(2) 创建tasks.json

ctrl + shift + P后输入Tasks: Configure Tasks

内容改为

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "command": "./build.sh",
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

(3) 编译

ctrl + shift + P后输入Tasks: Run Build Task或者快捷键ctrl + shift + B,就可以运行build.sh文件(执行tasks.json中的command指令)。


(4) 调试。快捷键Ctrl+Shift+D,打开一个launch.json。修改为
```c
{
    // 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++ - 生成和调试活动文件",
            "type": "cppdbg",
            "request": "launch",
            "program": "/...存放的路径.../ORB_SLAM3/Examples/Monocular/mono_euroc",
            "args": ["/...存放的路径.../ORB_SLAM3/Vocabulary/ORBvoc.txt",
                     "/...存放的路径.../ORB_SLAM3/Examples/Monocular/EuRoC.yaml",
                     "/...存放的路径.../ORB_SLAM3/Examples/Monocular/dataset/MH04",
                     "/...存放的路径.../ORB_SLAM3/Examples/Monocular/EuRoC_TimeStamps/MH04.txt"
                     ],
            "stopAtEntry": false,
            "preLaunchTask": "build",//这一步的build与tasks.json中的type名字相同
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

然后按左上角的g++前面的蓝色三角按钮,即可进行调试
ubuntu 16.04 vs code中调试ORB-SLAM3

参考
https://blog.csdn.net/weixin_45834800/article/details/125092249

原文链接: https://www.cnblogs.com/vivian187/p/16647547.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍;

也有高质量的技术群,里面有嵌入式、搜广推等BAT大佬

    ubuntu 16.04 vs code中调试ORB-SLAM3

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/396671

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年4月7日 上午9:07
下一篇 2023年4月7日 上午9:07

相关推荐