ubuntu 16.04 vs code中调试ORB-SLAM3

2022/9/2 5:22:46

本文主要是介绍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++前面的蓝色三角按钮,即可进行调试

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



这篇关于ubuntu 16.04 vs code中调试ORB-SLAM3的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程