编译和使用basalt时出现的报错

把总结写在前面

  1. 请使用GCC9或以上版本编译basalt
  2. 如果apt安装的fmt版本太低,请编译安装高一点版本的fmt
  3. 使用CLion编译请在配置好运行时的LD_LIBRARY_PATH

报错一:
github/basalt/thirdparty/Pangolin/src/image/image_io_lz4.cpp:42:12: error: ‘char* strncpy(char*, const char*, size_t)’ output truncated before terminating nul copying 3 bytes from a string of the same length [-Werror=stringop-truncation]

 strncpy(header.magic,"LZ4",3);

 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

cc1plus: all warnings being treated as errors
这个报错是由于在CMake的C++编译选项中添加了-Werror,即将所有警告当作错误对待,这个strncpy函数,由于是C风格的函数,拷贝字符串后面没有加’\0’这个结束符,但是这里其实不需要加结束符,因此在项目中全文搜索-Werror的位置,然后空一格在后面加上-Wno-error=stringop-truncation就行。

报错二:

In file included 
from XXX/github/basalt/thirdparty/basalt-headers/thirdparty/eigen/Eigen/src/Geometry/AlignedBox.h:49,
from XXX/github/basalt/thirdparty/Pangolin/include/pangolin/plot/range.h:43,
from XXX/github/basalt/thirdparty/Pangolin/include/pangolin/image/image_utils.h:34,
from XXX/github/basalt/thirdparty/Pangolin/include/pangolin/handler/handler_image.h:30,
from /home/vipl/VIPL2021-CJ/github/basalt/thirdparty/Pangolin/src/handler/handler_image.cpp:1:

/home/vipl/VIPL2021-CJ/github/basalt/thirdparty/basalt-headers/thirdparty/eigen/Eigen/src/Geometry/InternalHeaderCheck.h:2:2: error: #error "Please include Eigen/Geometry instead of including headers inside the src directory directly."

 #error "Please include Eigen/Geometry instead of including headers inside the src directory directly."

这个报错是因为代码中检查了是否直接包含AlignedBox.h,即在range.h中直接使用了

#include <Eigen/src/Geometry/AlignedBox.h>

然后在AlignedBox.h中,有一个#include "./InternalHeaderCheck.h"直接检查了出来。
因此报错了,需要将range.h中的

#include <Eigen/src/Geometry/AlignedBox.h>
修改为
#include <Eigen/Geometry>

报错三:
[ 87%] Building CXX object CMakeFiles/basalt.dir/src/utils/time_utils.cpp.o

In file included from /home/vipl/VIPL2021-CJ/github/basalt/src/utils/time_utils.cpp:2:

/home/vipl/VIPL2021-CJ/github/basalt/include/basalt/utils/format.hpp: In instantiation of ‘basalt::literals::operator""_format(const char*, size_t)::<lambda(auto:1&& …)> [with auto:1 = {const std::__cxx11::basic_string<char, std::char_traits, std::allocator >&, int&, double&, double&, double&, double&}]’:

/home/vipl/VIPL2021-CJ/github/basalt/src/utils/time_utils.cpp:134:56: required from here

/home/vipl/VIPL2021-CJ/github/basalt/include/basalt/utils/format.hpp:53:23: error: no matching function for call to ‘format(std::string_view, const std::__cxx11::basic_string&, int&, double&, double&, double&, double&)’

 return fmt::format(std::string_view(s, n), args...);

        ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

这个报错是GCC版本的原因,我使用的是GCC8.3.0,虽然已经全面支持C++17了,但是我不知道为什么开启不了C++17的特性,这个问题也不不想研究太深了,直接下载GCC9或者以上的版本,然后编译安装,使用update-alternative进行版本管理,需要注意在LD_LIBRARY_PATH里面添加GCC新的版本库目录,fmt也要使用新的GCC编译过后再安装,而且不要使用apt方式安装fmt,我使用的是deepin,apt源里面的libfmt库是5.2.1好像,太老了,直接下载8.1.1版本的,使用新的GCC编译后安装,然后再编译

报错四:
点击debug调试的时候,可执行文件显示链接到了/lib/x86_64-linux-gnu/libstdc++.so…这个库,这个库不支持新的GLIBCXX.3.29等等
在这里插入图片描述
这是因为CLion运行时配置里面没有设置环境变量LD_LIBRARY_PATH,感觉就直接使用的系统库目录,配置好LD_LIBRARY_PATH之后就可以运行
在CLION的运行->编辑配置->左侧选取你要debug的程序,然后设置环境变量就行。

注意事项一
打印用于标定的Apriltag中tag id的排列要按照如下方式排列
在这里插入图片描述
注意事项二
basalt_calibrate代码中默认的blackborder,也就是黑色边框的宽度是2像素,如果你要1个像素的Apriltag,需要在项目中修改响应的blackborder的值为1。

猜你喜欢

转载自blog.csdn.net/u013238941/article/details/125085428