关于slam14讲中ch7编译问题及解决方案

1.make编译时报错

/usr/bin/ld: CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: in function `unsigned long long fmt::v10::detail::width_checker::operator()<float, 0>(float) [clone .isra.0]':
pose_estimation_3d2d.cpp:(.text+0xe): undefined reference to `fmt::v10::report_error(char const*)'
/usr/bin/ld: CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: in function `unsigned long long fmt::v10::detail::precision_checker::operator()<float, 0>(float) [clone .isra.0]':
pose_estimation_3d2d.cpp:(.text+0x2e): undefined reference to `fmt::v10::report_error(char const*)'
/usr/bin/ld: CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: in function `bundleAdjustmentGaussNewton(std::vector<Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::aligned_allocator<Eigen::Matrix<double, 3, 1, 0, 3, 1> > > const&, std::vector<Eigen::Matrix<double, 2, 1, 0, 2, 1>, Eigen::aligned_allocator<Eigen::Matrix<double, 2, 1, 0, 2, 1> > > const&, cv::Mat const&, Sophus::SE3<double, 0>&)':
pose_estimation_3d2d.cpp:(.text+0x371f): undefined reference to `fmt::v10::vprint_locked(_IO_FILE*, fmt::v10::basic_string_view<char>, fmt::v10::basic_format_args<fmt::v10::context>)'
/usr/bin/ld: pose_estimation_3d2d.cpp:(.text+0x3748): undefined reference to `fmt::v10::vprint_locked(_IO_FILE*, fmt::v10::basic_string_view<char>, fmt::v10::basic_format_args<fmt::v10::context>)'
/usr/bin/ld: CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: in function `Sophus::SE3<double, 0>::exp(Eigen::Matrix<double, 6, 1, 0, 6, 1> const&)':
pose_estimation_3d2d.cpp:(.text._ZN6Sophus3SE3IdLi0EE3expERKN5Eigen6MatrixIdLi6ELi1ELi0ELi6ELi1EEE[_ZN6Sophus3SE3IdLi0EE3expERKN5Eigen6MatrixIdLi6ELi1ELi0ELi6ELi1EEE]+0x7b0): undefined reference to `fmt::v10::vprint_locked(_IO_FILE*, fmt::v10::basic_string_view<char>, fmt::v10::basic_format_args<fmt::v10::context>)'
/usr/bin/ld: pose_estimation_3d2d.cpp:(.text._ZN6Sophus3SE3IdLi0EE3expERKN5Eigen6MatrixIdLi6ELi1ELi0ELi6ELi1EEE[_ZN6Sophus3SE3IdLi0EE3expERKN5Eigen6MatrixIdLi6ELi1ELi0ELi6ELi1EEE]+0x7d9): undefined reference to `fmt::v10::vprint_locked(_IO_FILE*, fmt::v10::basic_string_view<char>, fmt::v10::basic_format_args<fmt::v10::context>)'
/usr/bin/ld: CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: in function `VertexPose::oplusImpl(double const*)':
pose_estimation_3d2d.cpp:(.text._ZN10VertexPose9oplusImplEPKd[_ZN10VertexPose9oplusImplEPKd]+0x368): undefined reference to `fmt::v10::vprint_locked(_IO_FILE*, fmt::v10::basic_string_view<char>, fmt::v10::basic_format_args<fmt::v10::context>)'
/usr/bin/ld: CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o:pose_estimation_3d2d.cpp:(.text._ZN10VertexPose9oplusImplEPKd[_ZN10VertexPose9oplusImplEPKd]+0x38e): more undefined references to `fmt::v10::vprint_locked(_IO_FILE*, fmt::v10::basic_string_view<char>, fmt::v10::basic_format_args<fmt::v10::context>)' follow
/usr/bin/ld: CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: in function `char const* fmt::v10::detail::parse_format_specs<char>(char const*, char const*, fmt::v10::detail::dynamic_format_specs<char>&, fmt::v10::basic_format_parse_context<char>&, fmt::v10::detail::type)':
pose_estimation_3d2d.cpp:(.text._ZN3fmt3v106detail18parse_format_specsIcEEPKT_S5_S5_RNS1_20dynamic_format_specsIS3_EERNS0_26basic_format_parse_contextIS3_EENS1_4typeE[_ZN3fmt3v106detail18parse_format_specsIcEEPKT_S5_S5_RNS1_20dynamic_format_specsIS3_EERNS0_26basic_format_parse_contextIS3_EENS1_4typeE]+0x211): undefined reference to `fmt::v10::report_error(char const*)'
/usr/bin/ld: pose_estimation_3d2d.cpp:(.text._ZN3fmt3v106detail18parse_format_specsIcEEPKT_S5_S5_RNS1_20dynamic_format_specsIS3_EERNS0_26basic_format_parse_contextIS3_EENS1_4typeE[_ZN3fmt3v106detail18parse_format_specsIcEEPKT_S5_S5_RNS1_20dynamic_format_specsIS3_EERNS0_26basic_format_parse_contextIS3_EENS1_4typeE]+0x4e7): undefined reference to `fmt::v10::report_error(char const*)'
/usr/bin/ld: pose_estimation_3d2d.cpp:(.text._ZN3fmt3v106detail18parse_format_specsIcEEPKT_S5_S5_RNS1_20dynamic_format_specsIS3_EERNS0_26basic_format_parse_contextIS3_EENS1_4typeE[_ZN3fmt3v106detail18parse_format_specsIcEEPKT_S5_S5_RNS1_20dynamic_format_specsIS3_EERNS0_26basic_format_parse_contextIS3_EENS1_4typeE]+0x910): undefined reference to `fmt::v10::report_error(char const*)'
/usr/bin/ld: pose_estimation_3d2d.cpp:(.text._ZN3fmt3v106detail18parse_format_specsIcEEPKT_S5_S5_RNS1_20dynamic_format_specsIS3_EERNS0_26basic_format_parse_contextIS3_EENS1_4typeE[_ZN3fmt3v106detail18parse_format_specsIcEEPKT_S5_S5_RNS1_20dynamic_format_specsIS3_EERNS0_26basic_format_parse_contextIS3_EENS1_4typeE]+0x94f): undefined reference to `fmt::v10::report_error(char const*)'
/usr/bin/ld: pose_estimation_3d2d.cpp:(.text._ZN3fmt3v106detail18parse_format_specsIcEEPKT_S5_S5_RNS1_20dynamic_format_specsIS3_EERNS0_26basic_format_parse_contextIS3_EENS1_4typeE[_ZN3fmt3v106detail18parse_format_specsIcEEPKT_S5_S5_RNS1_20dynamic_format_specsIS3_EERNS0_26basic_format_parse_contextIS3_EENS1_4typeE]+0xa08): undefined reference to `fmt::v10::report_error(char const*)'
/usr/bin/ld: CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o:pose_estimation_3d2d.cpp:(.text._ZN3fmt3v106detail18parse_format_specsIcEEPKT_S5_S5_RNS1_20dynamic_format_specsIS3_EERNS0_26basic_format_parse_contextIS3_EENS1_4typeE[_ZN3fmt3v106detail18parse_format_specsIcEEPKT_S5_S5_RNS1_20dynamic_format_specsIS3_EERNS0_26basic_format_parse_contextIS3_EENS1_4typeE]+0xa14): more undefined references to `fmt::v10::report_error(char const*)' follow
/usr/bin/ld: CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: in function `fmt::v10::detail::counting_iterator fmt::v10::detail::write_escaped_string<char, fmt::v10::detail::counting_iterator>(fmt::v10::detail::counting_iterator, fmt::v10::basic_string_view<char>)':
pose_estimation_3d2d.cpp:(.text._ZN3fmt3v106detail20write_escaped_stringIcNS1_17counting_iteratorEEET0_S4_NS0_17basic_string_viewIT_EE[_ZN3fmt3v106detail20write_escaped_stringIcNS1_17counting_iteratorEEET0_S4_NS0_17basic_string_viewIT_EE]+0x25e): undefined reference to `fmt::v10::detail::is_printable(unsigned int)'
/usr/bin/ld: pose_estimation_3d2d.cpp:(.text._ZN3fmt3v106detail20write_escaped_stringIcNS1_17counting_iteratorEEET0_S4_NS0_17basic_string_viewIT_EE[_ZN3fmt3v106detail20write_escaped_stringIcNS1_17counting_iteratorEEET0_S4_NS0_17basic_string_viewIT_EE]+0x2d8): undefined reference to `fmt::v10::detail::is_printable(unsigned int)'
/usr/bin/ld: pose_estimation_3d2d.cpp:(.text._ZN3fmt3v106detail20write_escaped_stringIcNS1_17counting_iteratorEEET0_S4_NS0_17basic_string_viewIT_EE[_ZN3fmt3v106detail20write_escaped_stringIcNS1_17counting_iteratorEEET0_S4_NS0_17basic_string_viewIT_EE]+0x518): undefined reference to `fmt::v10::detail::is_printable(unsigned int)'
/usr/bin/ld: CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: in function `fmt::v10::basic_appender<char> fmt::v10::detail::write_escaped_string<char, fmt::v10::basic_appender<char> >(fmt::v10::basic_appender<char>, fmt::v10::basic_string_view<char>)':
pose_estimation_3d2d.cpp:(.text._ZN3fmt3v106detail20write_escaped_stringIcNS0_14basic_appenderIcEEEET0_S5_NS0_17basic_string_viewIT_EE[_ZN3fmt3v106detail20write_escaped_stringIcNS0_14basic_appenderIcEEEET0_S5_NS0_17basic_string_viewIT_EE]+0x326): undefined reference to `fmt::v10::detail::is_printable(unsigned int)'
/usr/bin/ld: pose_estimation_3d2d.cpp:(.text._ZN3fmt3v106detail20write_escaped_stringIcNS0_14basic_appenderIcEEEET0_S5_NS0_17basic_string_viewIT_EE[_ZN3fmt3v106detail20write_escaped_stringIcNS0_14basic_appenderIcEEEET0_S5_NS0_17basic_string_viewIT_EE]+0x383): undefined reference to `fmt::v10::detail::is_printable(unsigned int)'
/usr/bin/ld: CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o:pose_estimation_3d2d.cpp:(.text._ZN3fmt3v106detail20write_escaped_stringIcNS0_14basic_appenderIcEEEET0_S5_NS0_17basic_string_viewIT_EE[_ZN3fmt3v106detail20write_escaped_stringIcNS0_14basic_appenderIcEEEET0_S5_NS0_17basic_string_viewIT_EE]+0x586): more undefined references to `fmt::v10::detail::is_printable(unsigned int)' follow
/usr/bin/ld: CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: in function `g2o::BaseUnaryEdge<2, Eigen::Matrix<double, 2, 1, 0, 2, 1>, VertexPose>::linearizeOplus()':
pose_estimation_3d2d.cpp:(.text._ZN3g2o13BaseUnaryEdgeILi2EN5Eigen6MatrixIdLi2ELi1ELi0ELi2ELi1EEE10VertexPoseE14linearizeOplusEv[_ZN3g2o13BaseUnaryEdgeILi2EN5Eigen6MatrixIdLi2ELi1ELi0ELi2ELi1EEE10VertexPoseE14linearizeOplusEv]+0xdcd): undefined reference to `fmt::v10::vprint_locked(_IO_FILE*, fmt::v10::basic_string_view<char>, fmt::v10::basic_format_args<fmt::v10::context>)'
/usr/bin/ld: pose_estimation_3d2d.cpp:(.text._ZN3g2o13BaseUnaryEdgeILi2EN5Eigen6MatrixIdLi2ELi1ELi0ELi2ELi1EEE10VertexPoseE14linearizeOplusEv[_ZN3g2o13BaseUnaryEdgeILi2EN5Eigen6MatrixIdLi2ELi1ELi0ELi2ELi1EEE10VertexPoseE14linearizeOplusEv]+0xdf3): undefined reference to `fmt::v10::vprint_locked(_IO_FILE*, fmt::v10::basic_string_view<char>, fmt::v10::basic_format_args<fmt::v10::context>)'
/usr/bin/ld: CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp.o: in function `g2o::BaseVertex<6, Sophus::SE3<double, 0> >::solveDirect(double)':
pose_estimation_3d2d.cpp:(.text._ZN3g2o10BaseVertexILi6EN6Sophus3SE3IdLi0EEEE11solveDirectEd[_ZN3g2o10BaseVertexILi6EN6Sophus3SE3IdLi0EEEE11solveDirectEd]+0x8cd): undefined reference to `fmt::v10::vprint_locked(_IO_FILE*, fmt::v10::basic_string_view<char>, fmt::v10::basic_format_args<fmt::v10::context>)'
/usr/bin/ld: pose_estimation_3d2d.cpp:(.text._ZN3g2o10BaseVertexILi6EN6Sophus3SE3IdLi0EEEE11solveDirectEd[_ZN3g2o10BaseVertexILi6EN6Sophus3SE3IdLi0EEEE11solveDirectEd]+0x8f3): undefined reference to `fmt::v10::vprint_locked(_IO_FILE*, fmt::v10::basic_string_view<char>, fmt::v10::basic_format_args<fmt::v10::context>)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/pose_estimation_3d2d.dir/build.make:102:pose_estimation_3d2d] 错误 1
make[1]: *** [CMakeFiles/Makefile2:86:CMakeFiles/pose_estimation_3d2d.dir/all] 错误 2
make: *** [Makefile:84:all] 错误 2

        根据报错原因,是因为没有链接到fmt库的原因,只需要在CMakeLists.txt文件中加入fmt链接即可:

add_executable(orb_cv orb_cv.cpp)
target_link_libraries(orb_cv ${OpenCV_LIBS} fmt::fmt)

add_executable(orb_self orb_self.cpp)
target_link_libraries(orb_self ${OpenCV_LIBS} fmt::fmt)

# add_executable( pose_estimation_2d2d pose_estimation_2d2d.cpp extra.cpp ) # use this if in OpenCV2 
add_executable(pose_estimation_2d2d pose_estimation_2d2d.cpp)
target_link_libraries(pose_estimation_2d2d ${OpenCV_LIBS} fmt::fmt)

# # add_executable( triangulation triangulation.cpp extra.cpp) # use this if in opencv2
add_executable(triangulation triangulation.cpp)
target_link_libraries(triangulation ${OpenCV_LIBS} fmt::fmt)

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

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

然后在重新进行编译,就可以生成对应的可执行文件了。

2.运行可执行文件

orb_cv.cpp(在高翔老师视频中为feature_extration.cpp)

        根据程序可以看出在运行对应的可执行文件时,还需要声明对应的图片。

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

        然后就可以观察到匹配的特征点了。

注:其他程序对应上述方法即可解决。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值