SLAM14讲——ch4,轨迹计算报错解决

文章描述了在C++项目中遇到的链接fmt库失败的错误,通过修改CMakeLists.txt中的链接库指令解决了问题。此外,还解决了运行时找不到txt文件的问题,通过将文件路径更改为绝对路径来确保程序能找到所需文件。最终,成功执行程序并获取轨迹误差评估结果。
摘要由CSDN通过智能技术生成

出现以下报错:

[ 50%] Linking CXX executable trajectoryError

/usr/bin/ld: CMakeFiles/trajectoryError.dir/trajectoryError.cpp.o: in function `std::make_unsigned<int>::type fmt::v8::detail::to_unsigned<int>(int)':

trajectoryError.cpp:(.text._ZN3fmt2v86detail11to_unsignedIiEENSt13make_unsignedIT_E4typeES4_[_ZN3fmt2v86detail11to_unsignedIiEENSt13make_unsignedIT_E4typeES4_]+0x23): undefined reference to `fmt::v8::detail::assert_fail(char const*, int, char const*)'

说明fmt库没有链接成功,因此需要链接fmt库,方法如下:

将CMakeLists.txt中:

target_link_libraries(trajectoryError ${Pangolin_LIBRARIES} ${FMT_LIBRARIES})

改为:(注意下面fmt前面有空格!)

target_link_libraries(trajectoryError ${Pangolin_LIBRARIES} ${FMT_LIBRARIES} fmt)

再次编译,问题解决。

运行时,新的问题出现:

trajectory ./example/groundtruth.txt not found.

trajectory ./example/estimated.txt not found

原因是没有找到需要的txt文件

解决方案:

编辑trajectoryError.cpp,将以下两行

string groundtruth_file = "./example/groundtruth.txt";

string estimated_file = "./example/estimated.txt";

转换为绝对路径:

string groundtruth_file = "../example/groundtruth.txt";

string estimated_file = "../example/estimated.txt";

再次编译后,再使用:

./trajectoryError

即可得到轨迹误差评估结果。

参考并使用该博主的一部分内容,且在其基础上解决了一部分问题:

https://blog.csdn.net/LNSTOP/article/details/125914717

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值