ORB_SLAM2 编译失败报错

编译前,对部分包的要求:

  1. Pangolin == 0.5
  2. Eigen >= 3.1.0 (可安装 3.1.0)
  3. OpenCV3 == 3.x.x(可安装 3.4.15)

通常,Eigen直接在终端使用 apt-get 安装 libeigen3-dev即可
Pangolin建议不要直接安装最新的版本,否则在编译过程中会出现 /usr/lib/ld cannot find lEigen3::Eigen 的错误导致编译失败
对于编译过程中的警告 EIGEN_DEPRECATED const unsigned int AlignedBit = 0x80; 可以忽略,不影响正常编译

对于报错:

  1. /usr/include/c++/9/bits/stl_map.h:122:71: error: static assertion failed: std::map must have the same value_type as its allocator :
    进入 ORB_SLAM2/include/ 修改 LoopClosing.h 文件第\(50\)
    原:typedef map<KeyFrame*, g2o::Sim3, std::less<KeyFrame*>, Eigen::aligned_allocator<std::pair<const KeyFrame*,g2o::Sim3> > > KeyFrameAndPose;
    修改为:typedef map<KeyFrame*, g2o::Sim3, std::less<KeyFrame*>, Eigen::aligned_allocator<std::pair<KeyFrame *const,g2o::Sim3> > > KeyFrameAndPose;
    即 修改 std::pair<const KeyFrame*,g2o::Sim3>std::pair<KeyFrame *const,g2o::Sim3>
  2. error: ‘usleep’ was not declared in this scope
    进入 ORB_SLAM2/include/ 修改 System.h 文件
    增加:#include<unistd.h>

预祝各位科研顺利,文章高中

posted @ 2024-10-13 11:44  GeneralMagic  阅读(226)  评论(0)    收藏  举报