g2o优化调试报错:‘Sophus::SE3::SE3()’未定义的引用

报错现象:
CMakeFiles/visualOdometry.dir/visualOdometry.cpp.o:在函数‘main’中:
visualOdometry.cpp:(.text.startup+0x7a):对‘Sophus::SE3::SE3()’未定义的引用
visualOdometry.cpp:(.text.startup+0x1528):对‘Sophus::SO3::SO3(double, double, double)’未定义的引用
visualOdometry.cpp:(.text.startup+0x1542):对‘Sophus::SE3::SE3(Sophus::SO3 const&, Eigen::Matrix const&)’未定义的引用
visualOdometry.cpp:(.text.startup+0x1555):对‘Sophus::SE3::operator=(Sophus::SE3 const&)’未定义的引用
…/…/lib/libslambase.a(slamBase.cpp.o):在函数‘estimateMotion(FRAME&, FRAME&, CAMERA_INTRINSIC_PARAMETERS&)’中:
slamBase.cpp:(.text+0xc89):对‘Sophus::SE3::SE3()’未定义的引用
collect2: error: ld returned 1 exit status
src/CMakeFiles/visualOdometry.dir/build.make:271: recipe for target ‘…/bin/visualOdometry’ failed
make[2]: *** […/bin/visualOdometry] Error 1
CMakeFiles/Makefile2:87: recipe for target ‘src/CMakeFiles/visualOdometry.dir/all’ failed
make[1]: *** [src/CMakeFiles/visualOdometry.dir/all] Error 2
Makefile:83: recipe for target ‘all’ failed
make: *** [all] Error 2

解决办法:
原因:没有连接到sohpus库,检查cmakelists

添加如下:
find_package( Sophus REQUIRED )
include_directories( ${Sophus_INCLUDE_DIRS} )

add_executable( useSophus useSophus.cpp )
target_link_libraries( useSophus ${Sophus_LIBRARIES} )

你可能感兴趣的:(Ubuntu)