Errors when compiling and using basalt

write the summary up front

  1. Please use GCC9 or above to compile basalt
  2. If the version of fmt installed by apt is too low, please compile and install a higher version of fmt
  3. When compiling with CLion, please configure the LD_LIBRARY_PATH at runtime

报错一:
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
This error is due to the addition of -Werror in the C++ compilation option of CMake, which treats all warnings as errors. This strncpy function, because it is a C-style function, does not add ' after the copy string \0' is the end character, but there is no need to add the end character here, so search for the position of -Werror in the full text of the project, and then add -Wno-error=stringop-truncation after a blank space.

Error two:

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."

This error is because the code checks whether AlignedBox.h is directly included, that is, it is directly used in range.h

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

Then in AlignedBox.h, there is a #include "./InternalHeaderCheck.h" checked out directly.
Therefore, an error is reported, and the range.h needs to be

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

Error three:
[ 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...);

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

This error is caused by the GCC version. I am using GCC8.3.0. Although it already fully supports C++17, I don’t know why the features of C++17 cannot be enabled. I don’t want to study this problem too deeply. Directly download GCC9 or above version, then compile and install, use update-alternative for version management, you need to pay attention to add GCC new version library directory in LD_LIBRARY_PATH, fmt should also use new GCC to compile and then install, and do not use apt method To install fmt, I use deepin. The libfmt library in the apt source seems to be 5.2.1, which is too old. Download the 8.1.1 version directly, compile it with the new GCC, install it, and then compile it again

Error 4:
When you click debug to debug, the executable file shows that it is linked to /lib/x86_64-linux-gnu/libstdc++.so... This library, this library does not support the new GLIBCXX.3.29, etc.
insert image description here
This is because of the CLion runtime configuration Without setting the environment variable LD_LIBRARY_PATH, I feel that the system library directory is used directly. After configuring LD_LIBRARY_PATH, it can be run. Run
in CLION -> Edit Configuration -> select the program you want to debug on the left, and then set the environment variable.

Note 1
The arrangement of the tag id in the Apriltag printed for calibration should be arranged in the following manner. Note
insert image description here
2
The default blackborder in the basalt_calibrate code, that is, the width of the black border is 2 pixels. The value of blackborder of the modification response in the project is 1.

Guess you like

Origin blog.csdn.net/u013238941/article/details/125085428