欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Ubuntu16.04运行slam14讲ch4完美调试后cmakelist修改记录

程序员文章站 2022-05-28 18:01:45
...

 trajectorError.cpp的cmaklist.txt修改记录:

cmake_minimum_required(VERSION 3.12)

option(USE_UBUNTU_16 "Set to ON if you are using Ubuntu 16.04" OFF)
add_definitions(-std=c++11)
find_package(Pangolin REQUIRED)
if(USE_UBUNTU_20)
    message("You are using Ubuntu 16.04, fmt::fmt will be linked")
    find_package(fmt REQUIRED)
    set(FMT_LIBRARIES fmt::fmt)
endif()
include_directories(${Pangolin_INCLUDE_DIRS})
add_executable(trajectoryError trajectoryError.cpp)
target_link_libraries(trajectoryError ${Pangolin_LIBRARIES} ${FMT_LIBRARIES})
target_link_libraries(trajectoryError ${Sophus_LIBRARIES} fmt)

 useSophus.cpp的cmakelist.txt修改记录:

cmake_minimum_required(VERSION 3.0)
project(useSophus)
add_definitions(-std=c++11)
# 为使用 sophus,需要使用find_package命令找到它
find_package(Sophus REQUIRED)
include_directories(${Sophus_INCLUDE_DIRS})
# Eigen
include_directories("/usr/local/include/eigen3")
add_executable(useSophus useSophus.cpp)
target_link_libraries(useSophus ${Sophus_LIBRARIES} fmt)

add_subdirectory(example)

编译通过后运行时报错未找到:

trajectory ./example/groundtruth.txt not found.
trajectory ./example/estimated.txt not found.
trajectoryError: /home/rui/slambook2/ch4/example/trajectoryError.cpp:22: int main(int, char**): Assertion `!groundtruth.empty() && !estimated.empty()' failed.

解决方法: 将cpp代码段此处修改为图中所示即可完美运行,原理解释是因为在kdevelop中目录分层问题。

Ubuntu16.04运行slam14讲ch4完美调试后cmakelist修改记录