视觉SLAM十四讲(一)--配置vscode编译环境

最近打算系统学习一下SLAM的知识,高翔博士的《视觉SLAM十四讲》是一本不错的入门课程,于是打算开个专题记录一下学习过程中出现的问题以及学习心得。

配置vscode C++编译环境

由于此教程的大部分代码都是由C++完成,为了方便在ubuntu系统下进行编程实践,所以使用Vscode集成环境进行代码编写,之前已经进行过简单的编译环境的配置,现在主要记录一下,当需要一个新的头文件的时候如何添加到编译环境中。

vscode环境的配置主要有三个比较重要的文件,tasks.json,launch.json以及c_cpp_properties.json

  • tasks.json
    主要进行修改args部分里面的内容,当需要添加头文件时就加上“-I/xxx/include/自己的路径”即可,其余各参数对应的意义不再赘述,网上有很多其他详细讲解
{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++ 生成活动文件",
            "command": "/usr/bin/g++",
            "args": [
                "-g",
                "${file}",
                "-I/usr/include/eigen3/",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "调试器生成的任务。"
        }
    ],
    "version": "2.0.0"
  • c_cpp_properties.json

主要用来添加头文件路径以及编译文件路径,值得注意的是,除了我们直接进行路径的添加之外,我们还可以添加complieCommands,这部分的详细教程在这里。经过实测,两种添加方式都可以独立起作用。

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
                "/usr/include/eigen3",
                "/usr/include/c++/7",
                "/usr/include/x86_64-linux-gnu/c++/7",
                "/usr/include/c++/7/backward",
                "/usr/lib/gcc/x86_64-linux-gnu/7/include",
                "/usr/local/include",
                "/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed",
                "/usr/include/x86_64-linux-gnu",
                "/usr/include"

            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "gnu11",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "linux-gcc-x64",
            "compileCommands": "${workspaceFolder}/compile_commands.json"
        }
    ],
    "version": 4
}
  • launch.json
{
    // 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": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++ 生成活动文件",
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}

你可能感兴趣的:(slam,ubuntu)