eigen3和g2o发生冲突

/usr/include/eigen3/Eigen/src/Core/util/StaticAssert.h:32: 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);
这是因为eigen3 和g2o冲突了

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

 template <typename MatrixType>
class LinearSolverEigen: public LinearSolver<MatrixType>
 {
   public:
    typedef Eigen::SparseMatrix<double, Eigen::ColMajor> SparseMatrix;
    typedef Eigen::Triplet<double> Triplet;
    typedef Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic, SparseMatrix::Index> PermutationMatrix;

 改成                                       
 template <typename MatrixType>
 class LinearSolverEigen: public LinearSolver<MatrixType>
 {
  public:
    typedef Eigen::SparseMatrix<double, Eigen::ColMajor> SparseMatrix;    
 typedef Eigen::Triplet<double> Triplet;
typedef Eigen::PermutationMatrix
<Eigen::Dynamic, Eigen::Dynamic, int> PermutationMatrix; /**

 stackoverflow里面还有人说通过解决更新换最新的eigen试试。通过改代码有后遗症。

原文地址:https://www.cnblogs.com/wjx-zjut/p/7107217.html