/home/ze/am/slambook-master/ch6/g2o_curve_fitting/main.cpp:77:49: error: no matching function for call to ‘g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::BlockSolver(g2o::BlockSolver<g2o::BlockSolverTraits<3, 1> >::LinearSolverType*&)’ Block* solver_ptr = new Block( linearSolver ); // 矩阵块求解器
通过查找百度查询,看到一篇博客展现了也是在编译高博视觉slam十四讲g2o环节出现问题的解决方案,http://blog.csdn.net/robinhjwy/article/details/78084210模仿这位作者的解决过程,修改了我的代码,
typedef g2o::BlockSolver<g2o::BlockSolverTraits<3,1> > Block; // 每个误差项优化变量维度为3,误差值维度为1 std::unique_ptr<Block::LinearSolverType> linearSolver ( new g2o::LinearSolverDense<Block::PoseMatrixType>()); //Block::LinearSolverType* linearSolver = new g2o::LinearSolverDense<Block::PoseMatrixType>(); // 线性方程求解器 std::unique_ptr<Block> solver_ptr ( new Block ( std::move(linearSolver))); //Block* solver_ptr = new Block( linearSolver ); // 矩阵块求解器 // 梯度下降方法,从GN, LM, DogLeg 中选 g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg ( std::move(solver_ptr)); //g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg( solver_ptr );
然后就编译成功了。
/home/ze/slam/slambook-master/ch6/g2o_curve_fitting/build> make -j4 [100%] Built target curve_fitting *** Finished ***