当前位置:   article > 正文

《视觉SLAM十四讲从理论到实践 第二版》Linux环境配置_cmake error at external/pybind11/tools/findpythonl

cmake error at external/pybind11/tools/findpythonlibsnew.cmake:95 (message):


前言

  • 操作系统为ubuntu18.04
  • 《视觉 SLAM 十四讲 第二版》源码GitHub
  • 安装依赖库 gcc、g++、make

sudo apt install build-essential

一、CMake

cmake 用来管理c++项目源代码

cmake ..  		根据CMakeLists.txt文件,生成makefile
make -j4  		根据makefile文件内容编译工程,即生成可执行文件
make install 	将可执行文件、第三方依赖包和文档安装到正确的路径
  • 1
  • 2
  • 3

安装cmake

cd cmake-3.**
./bootstrap
make -j4
sudo make install
  • 1
  • 2
  • 3
  • 4
  • 验证版本
cmake --version
  • 1
  • 若报错(Could not find OpenSSL),先执行以下代码再重复上述步骤安装:
sudo apt install libssl-dev
  • 1

二、OpenCV

安装OpenCV

  • 官网下载源码(本文使用的是4.3.0) https://opencv.org/releases/
    下载opencv以及opencv_contrib
  • 解压,并将opencv_contrib放置到opencv文件夹中
  • 安装依赖库
sudo apt install libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
# 处理图像所需的包
sudo apt install libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff5-dev libdc1394-22-dev 
sudo apt install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev liblapacke-dev
# 处理视频所需的包
sudo apt install libxvidcore-dev libx264-dev 
sudo apt install ffmpeg	
#可能需要安装的依赖
sudo apt install libjasper1 libjasper-dev
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 在终端进入目录执行:
#创建build 目录,并进入
sudo mkdir build

cd build
  • 1
  • 2
  • 3
  • 4
  • 配置cmake
sudo cmake -D CMAKE_BUILD_TYPE=Release -D OPENCV_GENERATE_PKGCONFIG=YES -D CMAKE_INSTALL_PREFIX=/usr/local/opencv  -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.3.0/modules -D OPENCV_ENABLE_NONFREE=True -D WITH_GTK=ON -D WITH_OPENMP=ON ..
  • 1

参数解释
cmake -D CMAKE_BUILD_TYPE=Release # 选择Release模式
OPENCV_GENERATE_PKGCONFIG=YES # 创建 PKGCONFIG文件
CMAKE_INSTALL_PREFIX=/usr/local/opencv # 安装路径
WITH_GTK=ON # ubuntu 上显示窗口必须加上这个

  • 编译并安装
#make的-j参数:多线程编译,参数可以是2,4,8,16
sudo make -j4
#安装
sudo make install
  • 1
  • 2
  • 3
  • 4

安装路径为:
/usr/local/opencv/include/opencv4
/usr/local/opencv/include
可自行查看是否安装成功

  • 报错

问题1: ~/opencv_contrib/modules/xfeatures2d/src/boostdesc.cpp:673:20: fatal error: boostdesc_bgm.i: No such file or directory
解决方法:链接: https://pan.baidu.com/s/1YzqO9PJUpflV8ivKuCRNuQ?pwd=slam 提取码: slam 将文件解压复制到opencv_contrib4.3.0/modules/xfeatures2d/src/

问题2:出现opencv-3.4.0/modules/stitching/include/opencv2/stitching/detail/matchers.hpp:52:12: fatal error: opencv2/xfeatures2d/cuda.hpp: No such file or directory
解决方法:在报错的那个module中,这里是stitching文件夹下的CMakeLists中添加:INCLUDE_DIRECTORIES(“/opencv-3.4.0/opencv_contrib-3.4.0/modules/xfeatures2d/include”)
注意路径

三、slam环境配置

安装Eigen

  • 终端输入:
sudo apt install libeigen3-dev
  • 1

安装Sophus(在slambook2/3rdpart/Sophus)

  • 终端进入slambook2/3rdpart/Sophus文件目录

  • 创建 build 目录并进入

sudo mkdir build 

cd build
  • 1
  • 2
  • 3
  • 生成Makefile
sudo cmake ..
  • 1
  • make编译
sudo make -j4
  • 1
  • 安装(可以不安装)
sudo make install
  • 1

安装Pangolin(在slambook2/3rdpart/Pangolin)

  • 终端进入slambook2/3rdpart/Pangolin文件目录
  • 安装依赖库
# OpenGL库
sudo apt install libglew-dev

sudo apt install pkg-config

sudo apt install doxygen
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 创建 build 目录并进入
sudo mkdir build 

cd build
  • 1
  • 2
  • 3
  • 生成Makefile
sudo cmake ..
  • 1
  • make编译
sudo make -j4
  • 1
  • 安装
sudo make install
  • 1

若CMake报错
错误信息
CMake Error at
external/pybind11/tools/FindPythonLibsNew.cmake:95 (message):
Python config failure: Traceback (most recent call last):
File “”, line 1, in ImportError: cannot import name ‘sysconfig’

  • 解决方法
sudo apt install python3-pip
  • 1

安装ceres(在slambook2/3rdparty/ceres-solver)

  • 终端进入slambook2/3rdparty/ceres-solver文件目录
  • 安装依赖库(glog、gtest)
# 日志和测试工具
sudo apt install liblapack-dev libsuitesparse-dev libcxsparse3 libgflags-dev libgoogle-glog-dev libgtest-dev 
  • 1
  • 2
  • 创建 build 目录并进入
sudo mkdir build 

cd build
  • 1
  • 2
  • 3
  • 生成Makefile
sudo cmake ..
  • 1
  • make编译
sudo make -j4
  • 1
  • 安装
sudo make install
  • 1

安装g2o(在slambook2/3rdparty/g2o)

  • 终端进入slambook2/3rdparty/g2o文件目录
  • 安装依赖库
sudo apt install qt5-qmake qt5-default libqglviewer-dev-qt5 libsuitesparse-dev libcxsparse3 libcholmod3
  • 1
  • 创建 build 目录并进入
sudo mkdir build 

cd build
  • 1
  • 2
  • 3
  • 生成Makefile
sudo cmake ..
  • 1
  • make编译
sudo make -j4
  • 1
  • 安装
sudo make install
  • 1

安装DBoW3(在slambook2/3rdparty/g2o)

需要优先安装OpenCV

  • 终端进入slambook2/3rdparty/g2o文件目录

  • 创建 build 目录并进入

sudo mkdir build 

cd build
  • 1
  • 2
  • 3
  • 生成Makefile
sudo cmake ..
  • 1
  • make编译
sudo make -j4
  • 1
  • 安装
sudo make install
  • 1

安装点云库PCL

  • 安装依赖库(vtk、boost)
sudo apt install libpcl-dev pcl-tools
  • 1

安装路径
/usr/include/vtk-6.3;/usr/include/boost
可自行查看

若报错
错误信息:
The following packages have unmet dependencies:libpcl-dev : Depends: libvtk6-dev but it is not going to be installed Depends: libvtk6-qt-dev but it is not going to be installed E: Unable to correct problems, you have held broken packages.

  • 解决方法
#使用aptitude 安装,先选择n,后选择y
sudo aptitude install libpcl-dev 
  • 1
  • 2

安装八叉树地图octomap与可视化工具octovis

sudo apt install liboctomap-dev octovis 
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/236873
推荐阅读
相关标签
  

闽ICP备14008679号