首先安装Sophus库,首先说明一下,我安装的是非模板类,非模板类相对模板类更好上手,且我下载的slam作者提供的sophus库压缩包也是非模板类。
一、下载
git clone https://github.com/strasdat/Sophus.git
cd Sophus
git checkout a621ff
二、编译
mkdir build
cd build
cmake ..
make
三、安装(注意:这一步可选也可不选,如果安装就相当于把头文件放在了系统的include目录下,把库文件放在了lib目录下,后面操作会方便一些)
sudo make install
到这里安装就完成,下面是CMakeLists.txt的编写规范:
cmake_minimum_required(VERSION 2.8)
find_package(Sophus REQUIRED)
message(STATUS ${Sophus_LIBRARIES})
include_directories(${Sophus_INCLUDE_DIRS})
add_executable(Sophhus Sophus.cpp)
target_link_libraries(Sophus ${Sophus_LIBRARIES})
需要注意:slam十四讲中编写程序是用模板类sophus库,而我下载的高翔的GitHub上压缩包是非模板类的sophus库,不知道大家是不是都这样,因此下载完库,需要对程序加以修改,将se3.hpp修改为se3.h,SE3d修改为SE3,这样程序就可以顺利通过编译了。