《视觉SLAM十四讲》 编译报错问题汇总 Ubuntu20.04

Ubuntu 20虚拟机环境安装

高翔原视频是ubuntu14.04,看了一下,有很多库都有兼容问题,所以初步按这个Ubuntu 20装:

这个教程是ubuntu20的,用ubuntu14会不兼容,比如qt5.12.12无法安装等(需要5.12.3)。和我之前安装的主要区别:之前用的是非虚拟机还装了ros的ubuntu20,现在裸ubuntu20.

视觉SLAM十四讲slambook2示例代码所有依赖库的编译安装教程(VTK、OpenCV3、ceres、Sophus、g2o、Eigen、Pangolin、googletest等)_zeeq_的博客-CSDN博客

全按教程去下载去安装(依赖包也是recursive连带下载的非最新版)

如果网络不好,需要去网页下的话,不要下这些包的最新版,他的那个是有特定版本的,@符号

《视觉SLAM十四讲》 编译报错问题汇总 Ubuntu20.04点进去可以看到是特定分支,可以下,但是不要通过搜索库直接去主支。

靠这个链接跳转的时候虽然链接特殊,HTTPS给的git指令还是和主支一致,所以不要用git clone如下链接

https://github.com/stevenlovegrove/Pangolin.git
https://github.com/stevenlovegrove/Pangolin.git

所以down zip是主支还是特定版本分支?从zip的解压情况看,是不一样的。

或者,git clone –recursive https://github.com/gaoxiang12/slambook2.git 可以直接下载库的相应分支。

小结:链接的教程用ubuntu20,并且没有强调第三方库用最新版,都是要用

git clone –recursive https://github.com/gaoxiang12/slambook2.git
一起下的旧版本,目前就按都兼容去假设。

总结,不要用ubuntu20.04.5,用原版源用不了,用清华源装完build-essential系统就不行了,崩,桌面崩溃或者找不到硬盘。

用20.04.3按照上面教程全部安装成功。下边是编译各章和遇到的问题。

==========================================

===================================================================

遇到的问题:

Pangolin编译不过

按下边方法注释掉两行可以解决,pangolinbuild出来的examples可以跑。

出现报错Pangolin X11: Unable to retrieve framebuffer options怎么办?_abcwoabcwo的博客-CSDN博客

opencv找不到

按前边的教程装了一个3.4.15.,里边有一长串依赖需要解决。按照教程做即可。

g2o无法编译

CMake Error at CMakeLists.txt:4 (project):
  No CMAKE_CXX_COMPILER could be found.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.
 

sudo apt-get update
sudo apt-get install -y build-essential

不能解决,需要手动安装g++

sudo apt install g++

分章解决和带ros的环境下的操作

如果按照前文教程操作,很多问题可能遇不到。

ch2

无,简单的cmake示例

ch3

编译错误:Pangolin找不到

"FindPangolin.cmake"相关提示。

下载

https://github.com/stevenlovegrove/Pangolin

git clone或者down zip

安装依赖

sudo apt-get install libglew-dev
sudo apt-get install libboost-dev libboost-thread-dev libboost-filesystem-dev

进入pangolin目录

mkdir build
cd build
cmake ..
make -j8

编译错误:sigslot系列error

各种基本的名称都是was not declared in this scope

/usr/local/include/sigslot/signal.hpp:109:79: error: ‘decay_t’ is not a member of ‘std’; did you mean ‘decay’?

比如 'm_slots'  'ptr'   'pmf'

因为ch3有很多例子,所以需要一个一个排查。

主要是visualizeGeometry那个例子里,把下边这句注释掉~,如果是IDE(vscode默认的缩进长度有点层级不分明),注意两层目录都有这句,都要注释

CMakeLists中set(CMAKE_CXX_FLAGS "-std=c++11")

运行plotTrajectory和visualizeGeometry报错


提示都是共享库    libpango_windowing.so  找不到

因为我用的是slambook2,不带3rdparty了,都是链接,需要自己下载pangolin,所以我适当怀疑版本不一样,或者下载出了什么偏差,删除我安装的,去实用slambook中的3rdparty压缩包。

(先别改旧源码的路径)进入build目录,记得加sudo

cd Pangolin/build
sudo make uninstall

然后找到slambook的Pangolin开始编译~

编译Pangolin时报ffmpeg错

经典老番,版本对不上,我用的Ubuntu20,不知道高翔的系统什么版本,可能是依赖库之类的有问题。

尝试把pangolin的ffmpeg关了,假设自己用pangolin用不到那么全面。。。

路径在Pangolin/src/CMakeLists.txt

内容大同小异,总之把find_package(FFMPEG QUIET)相关的东西给删了。


find_package(FFMPEG QUIET)
if(BUILD_PANGOLIN_VIDEO AND FFMPEG_FOUND)
  set(HAVE_FFMPEG 1)
  list(APPEND INTERNAL_INC  ${FFMPEG_INCLUDE_DIRS} )
  list(APPEND LINK_LIBS ${FFMPEG_LIBRARIES} )
  list(APPEND HEADERS ${INCDIR}/video/drivers/ffmpeg.h)
  list(APPEND SOURCES video/drivers/ffmpeg.cpp)
  list(APPEND VIDEO_FACTORY_REG RegisterFfmpegVideoFactory )
  list(APPEND VIDEO_FACTORY_REG RegisterFfmpegVideoOutputFactory )
 
  if(_GCC_)
    # FFMPEG is a real pain for deprecating the API.
    set_source_files_properties(video/drivers/ffmpeg.cpp    PROPERTIES COMPILE_FLAGS "-Wno-deprecated-declarations")
  endif()
  message(STATUS "ffmpeg Found and Enabled")

(pangolin官网推荐的ffmpeg安装方法,暂不尝试,是一个视频解码的依赖库,本例不需要

(deb) sudo apt-get install ffmpeg libavcodec-dev libavutil-dev libavformat-dev libswscale-dev

编译成功后,继续sudo make install

回到刚才的plotTrajectory和visualizeGeometry,不报错了。

plotTrajectory提示轨迹文件找不到

直接看代码,路径写死了

./examples/trajectory.txt。

但是目前编译的程序在build下,所以,要么改一下代码,要么在当前位置再创建一个文件夹,不赘述。

ch4

sophus找不到

从slambook/3rdparty里找到sophus编译安装

cmake报warning

make报error,lvalue和操作符的错。

在sohpusCMakeLists.txt加如下设置,没解决问题。

set(CMAKE_CXX_FLAGS "-Wno-error=deprecated-declarations -Wno-deprecated-declarations ")

安装sohpus报错:lvalue required as left operand of assignment

改源码

找到/Sophus/sophus目录下so2.cpp文件33行,如下代码:

    SO2::SO2()    
    {     
      unit_complex_.real() = 1.;     
      unit_complex_.imag() = 0.;
    }

修改为:

    SO2::SO2()    
    {     
      unit_complex_.real(1.);     
      unit_complex_.imag(0.);
    }

trajectoryerror.cpp引用错误:No Such file  #include <sohpus/se3.hpp>

仔细看了一下slambook/3rdparty给的Sophus,有se3.h,没有.hpp

改为#include <sohpus/se3.h>,测试,不通过,更多报错,

error: 'So3d' is not a member of 'Sophus';did you mean 'SO3'?

很可能是demo代码和sophus版本不匹配,毕竟连头文件都不一样,一个是hpp一个是h。

可能高博给的第三方库太久了,官方也是hpp,去官方下载。

GitHub – strasdat/Sophus: C++ implementation of Lie Groups using Eigen.

make uninstall 不一定都生效(取决于库是否提供对应操作),使用make -n install卸载sophus。

trajectoryerror.cpp引用报错: sophus common引用fmt出错,找不到

fatal error: fmt/format.h: No such file or directory

装一下fmt(fmt是一个iostream方面c和c++格式转换库)

git clone  https://github.com/fmtlib/fmt.git
cd fmt
mkdir build
cd build
cmake ..
make
sudo make install

trajectoryerror.cpp  linking出错

undefined reference to 'fmt::v9::detail::throw_format_error(char const*)'  等

注意顺序:安装fmt以后仅仅重装sophus不够,应该是重新编译并安装sophus,编译过程依赖。(虽然sophus没报错)高博原话是“Sophus编译了不用make install都可以”,所以重点是编译。

安装fmt成功之后

g++ test.cpp -lfmt可以编译通过并运行(test.cpp为自己引用fmt的测试程序)

但是高博的cmake不行

option(USE_UBUNTU_20 "Set to ON if you are using Ubuntu 20.04" OFF)
find_package(Pangolin REQUIRED)
if(USE_UBUNTU_20)
    message("You are using Ubuntu 20.04, fmt::fmt will be linked")
    find_package(fmt REQUIRED)
    set(FMT_LIBRARIES fmt::fmt)
endif()
include_directories(${Pangolin_INCLUDE_DIRS})
add_executable(trajectoryError trajectoryError.cpp)
target_link_libraries(trajectoryError ${Pangolin_LIBRARIES} ${FMT_LIBRARIES})

注意前边的option(USE_UBUNTU_20 "xxxxx" OFF)需要自己改成ON,因为我用的是ubuntu20.

option(USE_UBUNTU_20 "Set to ON if you are using Ubuntu 20.04" ON)

至此,CH4编译通过。

运行错误:Assertion '!groundtruth.empty() && !estimated.empty()' failed.

参考ch3,路径问题。

ch5

joinmap链接fmt出问题

 因为cmake没有fmt相关设置,把ch4的那部分设置复制过来改名即可

option(USE_UBUNTU_20 "Set to ON if you are using Ubuntu 20.04" OFF)
find_package(Pangolin REQUIRED)
if(USE_UBUNTU_20)
    message("You are using Ubuntu 20.04, fmt::fmt will be linked")
    find_package(fmt REQUIRED)
    set(FMT_LIBRARIES fmt::fmt)
endif()



include_directories(${Pangolin_INCLUDE_DIRS})
add_executable(joinMap joinMap.cpp)
target_link_libraries(joinMap $(OpenCV_LIBS) ${Pangolin_LIBRARIES} ${FMT_LIBRARIES})

joinMap运行不通过

老样子,把pose.txt复制到build相关目录,或者运行代码时在包含相应数据的路径下。

stereoVision报错

把相应图片复制到build相关目录,或者运行代码时在包含相应数据的路径下。

joinMap增加pcl实现版本

slambook2的代码没有使用pcl,而是自定义了一个pointcloud类型。

安装pcl

sudo apt-get install libpcl-dev pcl-tools

把slambook中的代码复制过去,相应的makefile贴过去,并且把C++改成14以上(ubuntu20.04)

运行通过,并产生pcd文件。

浏览pcd文件,不加-multiview会报错(多线程问题)

pcl_viewer -multiview 1 <pcd_filepath>

ch6

G2O_INCLUDE_DIRS找不到

Found Ceres version:1.14.0 installed in   

CMake Error: The following variables are used in this project, but they are set to NOTFOUD.Please set them or make sure they are set and tested correctly in the CMake files:G2O_INCLUDE_DIRS

安装G2O,Ubuntu20(带ros)暂时没遇到依赖项问题,直接进去g2o的代码make即可。

未解决~!因为g2o只编译,未安装,补安装,解决。

error:'make_unique' is not a member of 'g2o'; did you mean 'std::make_unique'?

g2o/solver_dense.cpp at master · RainerKuemmerle/g2o · GitHub

g2o应该是有这个接口的,但是我的源代码没有,应该还是slambook给的包太老了。

github下载最新包,安装。

FixedArray 找不到成员

/home/isilab/rtabmap/corelib/src/optimizer/OptimizerG2O.cpp:2110:1:   required from here
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:165:14: error: ‘FixedArray {aka class ceres::internal::FixedArray<double, 6>}’ has no member named ‘fill’
   add_vertex.fill(0.);
   ~~~~~~~~~~~^~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:172:30: error: ‘FixedArray {aka class ceres::internal::FixedArray<double, 6>}’ has no member named ‘data’
     vertex->oplus(add_vertex.data());
                   ~~~~~~~~~~~^~~~
/usr/local/include/g2o/core/base_fixed_sized_edge.hpp:178:30: error: ‘FixedArray {aka class ceres::internal::FixedArray<double, 6>}’ has no member named ‘data’
     vertex->oplus(add_vertex.data());

https://github.com/ceres-solver/ceres-solver/blob/master/include/ceres/internal/fixed_array.h

ceres版本不够了,需要更新

因为装了ROS有版本冲突。如果怕版本冲突搞坏ros可以先不用g2o。

# Eigen 3.3.4 从仓库直接安装的
sudo apt install libeigen-dev
# Ceres 2.0.0
cd ceres-solver && git checkout 1.14.x
# g2o 最新版本

eigen版本查看

/usr/include/eigen3/Eigen/src/Core/util/Macros.h

eigen是3.3.7

ceres是1.14,但是不同安装路径有多个ceres

陷入无底洞了。ros、eigen、ceres、g2o,关联比较多,版本兼容问题较多。

Building ceres-solver fail with eigen3 "error: no type named ‘Literal’ in ‘struct

ceres编译不过,要去换一个旧eigen,别人的分享,

Eigen 3.2.92

eigen-eigen-ce5a455b34c0.tar.bz2_免费高速下载|百度网盘-分享无限制

仍然编译不过ceres,ros太恼人了

=========

===================


 

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
青葱年少的头像青葱年少普通用户
上一篇 2023年2月26日 上午10:27
下一篇 2023年2月26日 上午10:28

相关推荐