踩坑 视觉SLAM 十四讲第二版 ch7 编译及运行问题

博客主要围绕计算机视觉项目中出现的编译和运行问题展开。包括make时未链接到fmt的问题,通过在cmakelist.txt中加入fmt链接解决;cmake时找不到目标的问题,在CMakeLists.txt中设置路径后重新编译解决;运行时输入参数和图片路径问题,按要求输入参数或修改路径即可。

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

1.make时报错:

CMakeFiles/pose_estimation_3d3d.dir/pose_estimation_3d3d.cpp.o: In function `fmt::v8::appender fmt::v8::detail::write<char, fmt::v8::appender>(fmt::v8::appender, fmt::v8::basic_string_view<fmt::v8::type_identity<char>::type>, fmt::v8::basic_format_specs<char> const&, fmt::v8::detail::locale_ref) [clone .isra.1336]':
pose_estimation_3d3d.cpp:(.text+0x68c7): undefined reference to `fmt::v8::detail::error_handler::on_error(char const*)'

等等 有关 In function `fmt 的问题,就是说明,没有链接到fmt,我们只需要在cmakelist.txt中加入fmt 链接即可,方法如下:

在报错的cpp文件位置 下面加入 ${FMT_LIBRARIES} fmt,最后两部分修改后如下:

add_executable(pose_estimation_3d2d pose_estimation_3d2d.cpp)
target_link_libraries(pose_estimation_3d2d
        g2o_core g2o_stuff
        ${OpenCV_LIBS}
        ${FMT_LIBRARIES} fmt)      

add_executable(pose_estimation_3d3d pose_estimation_3d3d.cpp)
target_link_libraries(pose_estimation_3d3d
        g2o_core g2o_stuff
        ${OpenCV_LIBS}
        ${FMT_LIBRARIES} fmt)

2.cmake ..时 报错:

CMake Error at CMakeLists.txt:9 (add_executable):
  Target "useSophus" links to target "Sophus::Sophus" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?

解决方案:
在CMakeLists.txt中:加入

set(Sophus_DIR "/home/你自己的路径/Sophus/build")

重新编译: 搞定!

3.运行问题

 3.1  ./orb_cv 报错提示 usage: feature_extraction img1 img2

 因为img1和img2的位置需要你自己输入,因此输入命令:

./orb_cv ../1.png ../2.png

 3.2 ./orb_self 找不到图片路径

将源码相对路径修改为:

string first_file = "../1.png";
string second_file = "../2.png";

或者直接改成你自己的绝对路径也行,保存后重新编译,再次运行 ./orb_self

 3.3 ./pose_estimation_2d2d 或 ./triangulation 或./pose_estimation_3d2d  或./pose_estimation_3d3d 

 报错提示 usage: feature_extraction img1 img2

一样在命令后加入  ../1.png ../2.png 即可

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值