ORB_SLAM2 Ubuntu16.04编译错误

Ubuntu14.04一切正常,迁移到Ubuntu16.04后编译报错,提示:

/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h:745:3: error: static assertion failed:YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY
  EIGEN_CHECK_BINARY_COMPATIBILIY(Func,typename ActualDstTypeCleaned::Scalar,typename Src::Scalar);

[email protected]15-R2:~/work/ORB_SLAM2$ ./build.sh
Configuring and building Thirdparty/DBoW2 ...
mkdir: 无法创建目录"build": 文件已存在
-- Configuring done
-- Generating done
-- Build files have been written to: /home/vip/work/ORB_SLAM2/Thirdparty/DBoW2/build
[100%] Built target DBoW2
Configuring and building Thirdparty/g2o ...
mkdir: 无法创建目录"build": 文件已存在
-- BUILD TYPE:Release
-- Compiling on Unix
-- Configuring done
-- Generating done
-- Build files have been written to: /home/vip/work/ORB_SLAM2/Thirdparty/g2o/build
[100%] Built target g2o
Uncompress vocabulary ...
Configuring and building ORB_SLAM2 ...
mkdir: 无法创建目录"build": 文件已存在
Build type: Release
-- Using flag -std=c++11.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/vip/work/ORB_SLAM2/build
Scanning dependencies of target ORB_SLAM2
[  3%] Building CXX object CMakeFiles/ORB_SLAM2.dir/src/Optimizer.cc.o
In file included from /usr/include/eigen3/Eigen/Core:297:0,
                 from /usr/include/eigen3/Eigen/Dense:1,
                 from /usr/include/eigen3/Eigen/Eigen:1,
                 from /usr/local/include/pangolin/gl/gl.h:40,
                 from /usr/local/include/pangolin/pangolin.h:38,
                 from /home/vip/work/ORB_SLAM2/include/MapDrawer.h:27,
                 from /home/vip/work/ORB_SLAM2/include/Viewer.h:26,
                 from /home/vip/work/ORB_SLAM2/include/Tracking.h:28,
                 from /home/vip/work/ORB_SLAM2/include/LocalMapping.h:27,
                 from /home/vip/work/ORB_SLAM2/include/LoopClosing.h:25,
                 from /home/vip/work/ORB_SLAM2/include/Optimizer.h:31,
                 from /home/vip/work/ORB_SLAM2/src/Optimizer.cc:21:
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h: In instantiation of ‘void Eigen::internal::call_assignment_no_alias(Dst&, const Src&, const Func&) [with Dst = Eigen::Matrix<int, -1, 1>; Src = Eigen::Matrix<long int, -1, 1, 0, -1, 1>; Func = Eigen::internal::assign_op<int>]’:
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h:712:27:   required from ‘void Eigen::internal::call_assignment(Dst&, const Src&, const Func&, typename Eigen::internal::enable_if<(! Eigen::internal::evaluator_assume_aliasing<Src>::value), void*>::type) [with Dst = Eigen::Matrix<int, -1, 1>; Src = Eigen::Matrix<long int, -1, 1, 0, -1, 1>; Func = Eigen::internal::assign_op<int>; typename Eigen::internal::enable_if<(! Eigen::internal::evaluator_assume_aliasing<Src>::value), void*>::type = void*]’
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h:693:18:   required from ‘void Eigen::internal::call_assignment(Dst&, const Src&) [with Dst = Eigen::Matrix<int, -1, 1>; Src = Eigen::Matrix<long int, -1, 1, 0, -1, 1>]’
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h:682:32:   required from ‘Derived& Eigen::PlainObjectBase<Derived>::_set(const Eigen::DenseBase<OtherDerived>&) [with OtherDerived = Eigen::Matrix<long int, -1, 1, 0, -1, 1>; Derived = Eigen::Matrix<int, -1, 1>]’
/usr/include/eigen3/Eigen/src/Core/Matrix.h:225:24:   required from ‘Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::operator=(const Eigen::DenseBase<OtherDerived>&) [with OtherDerived = Eigen::Matrix<long int, -1, 1, 0, -1, 1>; _Scalar = int; int _Rows = -1; int _Cols = 1; int _Options = 0; int _MaxRows = -1; int _MaxCols = 1]’
/usr/include/eigen3/Eigen/src/Core/PermutationMatrix.h:367:17:   required from ‘Eigen::PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, IndexType>& Eigen::PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, IndexType>::operator=(const Eigen::PermutationBase<OtherDerived>&) [with Other = Eigen::PermutationMatrix<-1, -1, long int>; int SizeAtCompileTime = -1; int MaxSizeAtCompileTime = -1; _StorageIndex = int]’
/home/vip/work/ORB_SLAM2/Thirdparty/g2o/g2o/solvers/linear_solver_eigen.h:68:18:   required from ‘void g2o::LinearSolverEigen<MatrixType>::CholeskyDecomposition::analyzePatternWithPermutation(g2o::LinearSolverEigen<MatrixType>::SparseMatrix&, const PermutationMatrix&) [with MatrixType = Eigen::Matrix<double, 7, 7, 0, 7, 7>; g2o::LinearSolverEigen<MatrixType>::SparseMatrix = Eigen::SparseMatrix<double, 0>; g2o::LinearSolverEigen<MatrixType>::PermutationMatrix = Eigen::PermutationMatrix<-1, -1, long int>]’
/home/vip/work/ORB_SLAM2/Thirdparty/g2o/g2o/solvers/linear_solver_eigen.h:195:9:   required from ‘void g2o::LinearSolverEigen<MatrixType>::computeSymbolicDecomposition(const g2o::SparseBlockMatrix<MatrixType>&) [with MatrixType = Eigen::Matrix<double, 7, 7, 0, 7, 7>]’
/home/vip/work/ORB_SLAM2/Thirdparty/g2o/g2o/solvers/linear_solver_eigen.h:100:37:   required from ‘bool g2o::LinearSolverEigen<MatrixType>::solve(const g2o::SparseBlockMatrix<MatrixType>&, double*, double*) [with MatrixType = Eigen::Matrix<double, 7, 7, 0, 7, 7>]’
/home/vip/work/ORB_SLAM2/src/Optimizer.cc:1244:1:   required from here
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h:745:3: error: static assertion failed: YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY
   EIGEN_CHECK_BINARY_COMPATIBILIY(Func,typename ActualDstTypeCleaned::Scalar,typename Src::Scalar);
   ^
CMakeFiles/ORB_SLAM2.dir/build.make:350: recipe for target ‘CMakeFiles/ORB_SLAM2.dir/src/Optimizer.cc.o‘ failed
make[2]: *** [CMakeFiles/ORB_SLAM2.dir/src/Optimizer.cc.o] Error 1
CMakeFiles/Makefile2:67: recipe for target ‘CMakeFiles/ORB_SLAM2.dir/all‘ failed
make[1]: *** [CMakeFiles/ORB_SLAM2.dir/all] Error 2
Makefile:83: recipe for target ‘all‘ failed
make: *** [all] Error 2

error log

问题原因:Eigen3的bug

解决方法:打开Thirdparty/g2o/g2o/solvers/linear_solver_eigen.h,将以下代码

1 template <typename MatrixType>
2 class LinearSolverEigen: public LinearSolver<MatrixType>
3 {
4   public:
5     typedef Eigen::SparseMatrix<double, Eigen::ColMajor> SparseMatrix;
6     typedef Eigen::Triplet<double> Triplet;
7     typedef Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic, SparseMatrix::Index> PermutationMatrix;

改为

1 template <typename MatrixType>
2 class LinearSolverEigen: public LinearSolver<MatrixType>
3 {
4   public:
5     typedef Eigen::SparseMatrix<double, Eigen::ColMajor> SparseMatrix;
6     typedef Eigen::Triplet<double> Triplet;
8     typedef Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic, int> PermutationMatrix;
9     /**
时间: 2024-11-10 03:52:44

ORB_SLAM2 Ubuntu16.04编译错误的相关文章

Ubuntu16.04编译Android6.0/cm13.0教程及相关错误解决办法

一.必备工作 1.安装依赖库 sudo apt-get install libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev g++-multilib git flex bison gperf build-essential libncurses5-dev:i386 tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386 dpkg-dev libsdl1.2-dev li

如何完成Ubuntu16.04编译安装Nginx

NGINX可以用作http/https服务器.反向代理服务器.邮件代理服务器.负载平衡器.TLS终结者或缓存服务器.它的设计非常模块化.它有本地模块和由社区创建的第三方模块.它是用C语言编写的,它是一种非常快速和轻量级的软件.注意:NGINX有两个版本流并行运行--稳定和主线.两个版本都可以在生产服务器上使用.建议在生产中使用主线版本.从源代码中安装NGINX是相对"容易"的--下载最新版本的NGINX源代码,配置.构建和安装它.在本教程中,我将使用主线版本,在撰写本文时是1.13.1

ubuntu16.04编译安装imu_tk

imu_tk代码地址 https://bitbucket.org/alberto_pretto/imu_tk 安装依赖项 sudo apt-get install build-essential cmake libeigen3-dev libqt4-dev libqt4-opengl-dev freeglut3-dev gnuplot 安装ceres-solver https://www.cnblogs.com/feifanrensheng/p/8630149.html 编译安装imu_tk c

Ubuntu16.04编译Caffe

虽然说编译Caffe并成功执行才是这一系列博客的main dish,但实际上只要把依赖都装好,安装Caffe就是水到渠成的事情了. 我选择在~/.bashrc中将所有依赖添加好,然后source,这样就不必在Makefile.config中添加include环境依赖了,但是在LIBRARY_DIRS还是要老老实实把所有依赖的lib路径都写上. 在环境依赖添加好以后,直接make或make -j4什么的,等待结果就可以了. 遇到的问题: 1.我的leveldb比较新,里面用了很多C++11特性,编

ubuntu16.04编译安装php7.2

1,下载解压 tar xf php-7.2.0.tar.gz cd php-7.2.0/ 2,安装必要的库 sudo apt-get install libxml2-devsudo apt-get install openssl sudo apt-get install libssl-devsudo apt-get install makesudo apt-get install curlsudo apt-get install libcurl4-gnutls-devsudo apt-get i

ubuntu16.04编译安装mysql5.7

1.安装编译依赖 sudo apt-get install make cmake gcc g++ bison libncurses5-dev build-essential 2.下载mysql5.7并解压 下载地址: tar -xzf mysql-5.7.21.tar.gz -C /usr/localcd /usr/local/mysql-5.7.21 3.编译安装 cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/

Ubuntu16.04 appstreamcli错误

解决方案:https://askubuntu.com/questions/774986/appstreamcli-hanging-with-100-cpu-usage-during-update 搬运过来是: This is caused by a bug https://bugs.launchpad.net/ubuntu/+source/appstream/+bug/1579712The working solution (just tried myself): First kill apps

caffe在invidia+cpu 酷睿2Q9300 + ubuntu16.04.2上面的安装和编译过程

本文原创,转载请注明出处. ------------------------------------------------分割线-------------------------------- 概要:整个过程基本上是傻瓜模式的,不需要gcc4.9, 也不需要和gcc5.4的切换. 硬件:gtx650tiboost 酷睿2Q 9300四核 主板貌似技嘉的一个极老的小板子 环境: 系统:ubuntu16.04 86x64 gcc: 5.4 86x64 cuda8 : cuda-repo-ubunt

Ubuntu16.04配置Android5.0编译环境

1.安装jdk7 Ubuntu16.04的安装源已经默认没有openjdk7了,所以要自己手动添加仓库,如下: $ sudo add-apt-repository ppa:openjdk-r/ppa $ sudo apt-get update 安装openjdk-7-jdk $ sudo apt-get install openjdk-7-jdk openjdk-7-jre 如果安装成功之后还是不能用可能有多个版本,执行如下命令选择正确的版本:$ sudo update-alternatives