slam14讲-ch6-使用 g2o 拟合曲线编译问题记录

slam14讲-ch6-使用 g2o 拟合曲线编译问题记录

g2o版本

g2o-20201223_git

问题1

书中代码-适用于原版

    // 线性方程求解器:稠密的增量方程
   Block::LinearSolverType* linearSolver = new g2o::LinearSolverDense<Block::PoseMatrixType>();
Block* solver_ptr = new Block(linearSolver);//矩阵块求解器
//梯度下降方法
g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg( solver_ptr );

新版

    unique_ptr<Block::LinearSolverType> linearSolver(new g2o::LinearSolverDense<Block::PoseMatrixType>());
    unique_ptr<Block> solver_ptr ( new Block ( std::move(linearSolver)));
    g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg(std::move(solver_ptr));

问题2

#cmakelists
# 寻找 G2O 库
find_package(G2O REQUIRED)
# 添加头文件
include_directories( ${G2O_INCLUDE_DIRS})
target_link_libraries(g2o_curve_fitting ${G2O_CORE_LIBRARY})

编译问题

/usr/bin/ld: CMakeFiles/g2o_curve_fitting.dir/main.cpp.o: undefined reference to symbol '_ZN3g2o18get_monotonic_timeEv'
/usr/bin/ld: /usr/local/lib/libg2o_stuff.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

修改CMakeLists

#cmakelists
# 寻找 G2O 库
find_package(G2O REQUIRED)
# 添加头文件
include_directories( ${G2O_INCLUDE_DIRS})
SET(G2O_LIBS g2o_cli g2o_ext_freeglut_minimal g2o_simulator g2o_solver_slam2d_linear g2o_types_icp g2o_types_slam2d g2o_core g2o_interface g2o_solver_csparse g2o_solver_structure_only g2o_types_sba g2o_types_slam3d g2o_csparse_extension g2o_opengl_helper g2o_solver_dense g2o_stuff g2o_types_sclam2d g2o_parser g2o_solver_pcg g2o_types_data g2o_types_sim3 cxsparse )

target_link_libraries(g2o_curve_fitting ${G2O_LIBS})
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值