g20在ubuntu16.04中编译ORBSLAM2的问题解决

在编译ORBSLAM时出现的问题如下:

Scanning dependencies of target ORB_SLAM2-map

[  4%] Building CXX object CMakeFiles/ORB_SLAM2-map.dir/src/System.cc.o
[  8%] Building CXX object CMakeFiles/ORB_SLAM2-map.dir/src/Tracking.cc.o
[ 12%] Building CXX object CMakeFiles/ORB_SLAM2-map.dir/src/LocalMapping.cc.o
[ 16%] Building CXX object CMakeFiles/ORB_SLAM2-map.dir/src/LoopClosing.cc.o
[ 20%] Building CXX object CMakeFiles/ORB_SLAM2-map.dir/src/ORBextractor.cc.o
[ 25%] Building CXX object CMakeFiles/ORB_SLAM2-map.dir/src/ORBmatcher.cc.o
[ 29%] Building CXX object CMakeFiles/ORB_SLAM2-map.dir/src/FrameDrawer.cc.o
[ 33%] Building CXX object CMakeFiles/ORB_SLAM2-map.dir/src/Converter.cc.o
[ 37%] Building CXX object CMakeFiles/ORB_SLAM2-map.dir/src/MapPoint.cc.o
/home/pjz/zhushi/ORB_SLAM2-map/src/MapPoint.cc: In instantiation of ‘void ORB_SLAM2::MapPoint::load(Archive&, unsigned int) [with Archive = boost::archive::binary_oarchive]’:
/home/pjz/zhushi/ORB_SLAM2-map/src/MapPoint.cc:223:23:   required from here
/home/pjz/zhushi/ORB_SLAM2-map/src/MapPoint.cc:176:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < nItems; ++i) {
                           ^
/home/pjz/zhushi/ORB_SLAM2-map/src/MapPoint.cc: In instantiation of ‘void ORB_SLAM2::MapPoint::load(Archive&, unsigned int) [with Archive = boost::archive::binary_iarchive]’:
/home/pjz/zhushi/ORB_SLAM2-map/src/MapPoint.cc:226:23:   required from here
/home/pjz/zhushi/ORB_SLAM2-map/src/MapPoint.cc:176:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
[ 41%] Building CXX object CMakeFiles/ORB_SLAM2-map.dir/src/KeyFrame.cc.o
[ 45%] Building CXX object CMakeFiles/ORB_SLAM2-map.dir/src/Map.cc.o
[ 50%] Building CXX object CMakeFiles/ORB_SLAM2-map.dir/src/MapDrawer.cc.o
[ 54%] Building CXX object CMakeFiles/ORB_SLAM2-map.dir/src/Optimizer.cc.o
In file included from /usr/include/eigen3/Eigen/Core:297:0,
                 from /home/pjz/zhushi/ORB_SLAM2-map/Thirdparty/g2o/g2o/types/../core/jacobian_workspace.h:30,
                 from /home/pjz/zhushi/ORB_SLAM2-map/Thirdparty/g2o/g2o/types/../core/optimizable_graph.h:41,
                 from /home/pjz/zhushi/ORB_SLAM2-map/Thirdparty/g2o/g2o/types/../core/base_vertex.h:30,
                 from /home/pjz/zhushi/ORB_SLAM2-map/Thirdparty/g2o/g2o/types/types_seven_dof_expmap.h:34,
                 from /home/pjz/zhushi/ORB_SLAM2-map/include/LoopClosing.h:34,
                 from /home/pjz/zhushi/ORB_SLAM2-map/include/Optimizer.h:27,
                 from /home/pjz/zhushi/ORB_SLAM2-map/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/pjz/zhushi/ORB_SLAM2-map/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/pjz/zhushi/ORB_SLAM2-map/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/pjz/zhushi/ORB_SLAM2-map/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/pjz/zhushi/ORB_SLAM2-map/src/Optimizer.cc:1262:1:   required from here
/usr/include/eigen3/Eigen/src/Core/util/StaticAssert.h:32:40: error: static assertion failed: YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY
     #define EIGEN_STATIC_ASSERT(X,MSG) static_assert(X,#MSG);
                                        ^
/usr/include/eigen3/Eigen/src/Core/util/XprHelper.h:707:3: note: in expansion of macro ‘EIGEN_STATIC_ASSERT’
   EIGEN_STATIC_ASSERT((internal::functor_is_product_like<BINOP>::ret \
   ^
/usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h:745:3: note: in expansion of macro ‘EIGEN_CHECK_BINARY_COMPATIBILIY’
   EIGEN_CHECK_BINARY_COMPATIBILIY(Func,typename ActualDstTypeCleaned::Scalar,ty
   ^
CMakeFiles/ORB_SLAM2-map.dir/build.make:350: recipe for target 'CMakeFiles/ORB_SLAM2-map.dir/src/Optimizer.cc.o' failed
make[2]: *** [CMakeFiles/ORB_SLAM2-map.dir/src/Optimizer.cc.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/ORB_SLAM2-map.dir/all' failed
make[1]: *** [CMakeFiles/ORB_SLAM2-map.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

解决办法如下:

打开Thirdparty/g2o/g2o/solvers/linear_solver_eigen.h

找到如下代码:

typedef Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic, SparseMatrix::Index> PermutationMatrix; 
把上边的代码改为如下:

typedef Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic, int> PermutationMatrix;

即把红色的部分改为int;

改完保存,重新编译g2o的共享库,然后在编译orbslam2,就ok啦。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值