关于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);

  error log
 
问题原因:Eigen3的bug
解决方法: 打开Thirdparty/g2o/g2o/solvers/linear_solver_eigen.h,将以下代码
复制代码
1 template 
2 class LinearSolverEigen: public LinearSolver
3 {
4   public:
5     typedef Eigen::SparseMatrix<double, Eigen::ColMajor> SparseMatrix;
6     typedef Eigen::Triplet<double> Triplet;
7     typedef Eigen::PermutationMatrixSparseMatrix::Index> PermutationMatrix;
复制代码

改为

复制代码
1 template 
2 class LinearSolverEigen: public LinearSolver
3 {
4   public:
5     typedef Eigen::SparseMatrix<double, Eigen::ColMajor> SparseMatrix;
6     typedef Eigen::Triplet<double> Triplet;
8     typedef Eigen::PermutationMatrixint> PermutationMatrix;
9     /**
复制代码

你可能感兴趣的:(Daily letters)