gaoxiang12 / slambook2

edition 2 of the slambook
MIT License
5.52k stars 2.02k forks source link

ch9 #171

Closed iamkrs9 closed 3 years ago

iamkrs9 commented 3 years ago

Changed the CmakeLists.txt to

cmake_minimum_required(VERSION 2.8)

project(bundle_adjustment) set(CMAKE_BUILD_TYPE "Release") set(CMAKE_CXX_FLAGS "-O3 -std=c++11") set(CMAKE_CXX_STANDARD 14)

LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

Find_Package(G2O REQUIRED) Find_Package(Eigen3 REQUIRED) Find_Package(Ceres REQUIRED) Find_Package(Sophus REQUIRED) Find_Package(CSparse REQUIRED)

SET(G2O_LIBS "/usr/local/lib/libg2o_csparse_extension.dylib" "/usr/local/lib/libg2o_stuff.dylib" "/usr/local/lib/libg2o_core.dylib" "/usr/local/lib/libcxsparse.dylib")

include_directories(${PROJECT_SOURCE_DIR} ${EIGEN3_INCLUDE_DIR} ${CSPARSE_INCLUDE_DIR})

add_library(bal_common common.cpp) add_executable(bundle_adjustment_g2o bundle_adjustment_g2o.cpp) add_executable(bundle_adjustment_ceres bundle_adjustment_ceres.cpp)

target_link_libraries(bundle_adjustment_ceres ${CERES_LIBRARIES} bal_common) target_link_libraries(bundle_adjustment_g2o ${G2O_LIBS} bal_common)

Had to include .dylib by path in MacOS 11.3 for it to work