ceres 使用时链接报错

编译成功后出现:

/usr/local/lib/libceres.a(visibility_based_preconditioner.cc.o):在函数‘ceres::internal::VisibilityBasedPreconditioner::ComputeBlockPairsInPreconditioner(ceres::internal::CompressedRowBlockStructure const&)’中:
visibility_based_preconditioner.cc:(.text+0xd28):对‘google::kLogSiteUninitialized’未定义的引用
visibility_based_preconditioner.cc:(.text+0xdf0):对‘google::InitVLOG3__(int**, int*, char const*, int)’未定义的引用

解决方法:
在Cmakelists.txt中,target_link_libraries 里将 ${CERES_LIBRARIES} 调整到 ${GLOG_LIBRARIES} 之前,即:

target_link_libraries(${PROJECT_NAME}
  ${catkin_LIBRARIES}
  ${OpenCV_LIBS}
  ${EIGEN3_LIBS}
  ${PCL_LIBRARIES}
  ${CERES_LIBRARIES}
  ${GLOG_LIBRARIES}
)

你可能感兴趣的:(踩坑)