sophus编译错误,未定义相关函数

在视觉SLAM14讲的实践中,遇到sophus库编译后libSophus.so未被正确链接的问题。通过在CMakeLists.txt中添加特定指令,成功解决了Sophus_LIBRARIES未包含libSophus.so导致的编译错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

视觉SLAM14讲中,在编译完sophus库后,使用sudo make install安装后,经过编译发现错误,如下图
在这里插入图片描述
这是因为安装后打libSophus.so 没有被cmake链接到 Sophus_LIBRARIES, 因此出现这个错误。

在cmakelists中添加如下语句

include_directories( "/usr/local/include/suphos")
#FIND_PACKAGE(sophus REQUIRED)
set(Sophus_LIBRARIES libSophus.so)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${Sophus_LIBRARIES})
/usr/bin/ld: /home/dog/catkin_ws/devel/lib/libvikit_common.so: undefined reference to `Sophus::SE3::exp(Eigen::Matrix<double, 6, 1, 0, 6, 1> const&)' /usr/bin/ld: /home/dog/catkin_ws/devel/lib/libvikit_common.so: undefined reference to `Sophus::SE3::operator=(Sophus::SE3 const&)' /usr/bin/ld: /home/dog/catkin_ws/devel/lib/libvikit_common.so: undefined reference to `Sophus::SE3::SE3()' /usr/bin/ld: /home/dog/catkin_ws/devel/lib/libvikit_common.so: undefined reference to `Sophus::SE3::SE3(Sophus::SE3 const&)' /usr/bin/ld: /home/dog/catkin_ws/devel/lib/libvikit_common.so: undefined reference to `Sophus::SE3::operator*(Sophus::SE3 const&) const' /usr/bin/ld: /home/dog/catkin_ws/devel/lib/libvikit_common.so: undefined reference to `Sophus::SO3::matrix() const' /usr/bin/ld: /home/dog/catkin_ws/devel/lib/libvikit_common.so: undefined reference to `Sophus::SE3::SE3(Eigen::Matrix<double, 3, 3, 0, 3, 3> const&, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&)' /usr/bin/ld: /home/dog/catkin_ws/devel/lib/libvikit_common.so: undefined reference to `Sophus::SE3::operator*(Eigen::Matrix<double, 3, 1, 0, 3, 1> const&) const' collect2: error: ld returned 1 exit status make[2]: *** [rpg_vikit/vikit_common/CMakeFiles/test_vk_common_camera.dir/build.make:134: /home/dog/catkin_ws/devel/lib/vikit_common/test_vk_common_camera] Error 1 make[1]: *** [CMakeFiles/Makefile2:575: rpg_vikit/vikit_common/CMakeFiles/test_vk_common_camera.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... /usr/bin/ld: /home/dog/catkin_ws/devel/lib/libvikit_common.so: undefined reference to `Sophus::SE3::exp(Eigen::Matrix<double, 6, 1, 0, 6, 1> const&)' /usr/bin/ld: /home/dog/catkin_ws/devel/lib/libvikit_common.so: undefined reference to `Sophus::SE3::operator=(Sophus::SE3 const&)' /usr/bin/ld: /home/dog/catkin_ws/devel/lib/libvikit_common.so: undefined reference to `Sophus::SE3::SE3()' /usr/bin/ld: /home/dog/catkin_ws/devel/lib/libvikit_common.so: undefined reference to `Sophus::SE3::SE3(Sophus::SE3 const&)'
最新发布
04-03
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值