如果是在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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。