视觉SLAM十四讲第二版-CH7-Ubuntu18.04-运行报错recipe for target ‘pose_estimation_3d2d‘ faile和修改CMakelists.txt解决记录

视觉SLAM十四讲第二版-CH7-Ubuntu18.04-运行报错recipe for target ‘pose_estimation_3d2d’ failed 和修改CMakelists.txt解决记录:


问题描述:

先放修改后的CMakelists.txt再解释:

cmake_minimum_required(VERSION 2.8)
project(vo1)

set(CMAKE_BUILD_TYPE "Release")
add_definitions("-DENABLE_SSE")
set(CMAKE_CXX_FLAGS "-std=c++11 -O2 ${SSE_FLAGS} -msse4")
list(APPEND CMAKE_MODULE_PATH ${
   PROJECT_SOURCE_DIR}/cmake)

find_package(OpenCV 3 REQUIRED)
find_package(G2O REQUIRED)
find_package(Sophus REQUIRED)

include_directories(
        ${
   OpenCV_INCLUDE_DIRS}
        ${
   G2O_INCLUDE_DIRS}
        ${
   Sophus_INCLUDE_DIRS}
        "/usr/include/eigen3/"
)

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

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

# 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})

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

add_executable(pose_estimation_3d2d pose_estimation_3d2d.cpp)
target_link_libraries(pose_estimation_3d2d
 		${
   G2O_CORE_LIBRARY} ${
   G2O_STUFF_LIBRARY}
		${
   OpenCV_LIBS} fmt)

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

报错及解决:

这第一个问题,找了很久解决方案,去网上看了乱糟的解决方案各种尝试都没解决,甚至按照网上的提示熬夜安装其他依赖,没有解决,最后还是自己仔细看了报错,发现是没有pose_estimation_3d2d和pose_estimation_3d2d没有链接到fmt库,于是在CMakelists.txt中的target_link_libraries处添加相应的fmt库的链接问题便解决了,记录如下:
(1)在build中make阶段报错如下:

jesse@jesse-HP-ZHAN-66-Pro-14-G4-Notebook-PC:~/slambook2/ch7/build$ make
[ 16%] Built target orb_self
[ 33%] Built target orb_cv
[ 50%] Built target triangulation
[ 66%] Built target pose_estimation_2d2d
[ 75%] Linking CXX executable pose_estimation_3d2d
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+0x3d69): undefined reference to `fmt::v8::vprint(fmt::v8::basic_string_view<char>, fmt::v8::basic_format_args<fmt::v8::basic_format_context<fmt::v8::appender, char> >)'
CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.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.1610]':
pose_estimation_3d2d.cpp:(.text+0x4742): undefined reference to `fmt::v8::detail::throw_format_error(char const*)'
CMakeFiles/pose_estimation_3d2d.dir/pose_estimation_3d2d.cpp
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值