slam14講5.4.2程式修改

2020-10-26 11:00:32

原本的程式我的電腦上編譯出現了各種各樣的問題。

一、Sophus庫

參照我另一篇部落格進行修改:

https://blog.csdn.net/weixin_44986556/article/details/109154373

二、OpenCV庫

修改完Sophus之後,出現了大量關於OpenCV庫的問題,諸如:

undefined reference to `cv::imread(cv::String const&, int)'

因為同樣使用了OpenCV庫,所以我找來了7.2.2的CMakeLists.txt檔案仔細對比,將5.4.2原本的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)
################################################
add_executable(joinMap joinMap.cpp)

find_package(Sophus REQUIRED)
find_package(OpenCV 3 REQUIRED)
find_package(Pangolin REQUIRED)

target_link_libraries( joinMap ${OpenCV_LIBS})
target_link_libraries( joinMap ${Sophus_LIBRARIES} )
target_link_libraries( joinMap ${Pangolin_LIBRARIES})

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

編譯順利通過~