系统相关
首页 > 系统相关> > ubuntu 16.04 vs code中调试ORB-SLAM3

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

标签:...,code,16.04,json,SLAM3,build,ORB,调试
来源: https://www.cnblogs.com/vivian187/p/16647547.html