camke(4)配置sophus
作者:互联网
安装
参考教程
https://blog.csdn.net/fb_941219/article/details/104590842
老版本()slam第一版
非模板类-适用于SLAM14第一版讲代码 非模板类的头文件为**.h
git clone https://github.com/strasdat/Sophus.git
cd Sophus
git checkout a621ff #版本回溯 很重要切换到老版本
mkdir build && cd build && cmake .. && sudo make && sudo make install
修改一个报错
https://blog.csdn.net/qq_40641575/article/details/81006349
1 SO2::SO2()
2 {
3 //unit_complex_.real() = 1.;
4 //unit_complex_.imag() = 0.;
5 unit_complex_.real(1.);
6 unit_complex_.imag(0.);
7 }
新版本 slam第二版
模板类sophus SLAM14第二版代码 模板类的头文件为**.hpp
下载
git clone https://github.com/strasdat/Sophus.git
编译
$ cd Sophus
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install
如何共存两个版本
将某一个版本安装在制定目录,cmake导入的时候制定这个目录
如果想要共存 多版本使用,将模板类安装到指定文件夹
以先安装非模板类为例,第一次安装直接普通安装即可,模板类安装时指定文件夹,互不影响。
mkdir build
cd build
cmake -D CMAKE_INSTALL_PREFIX=/usr/local/sophus-template ..
make -j8
sudo make install
这个种模式下
--------camke 编写----------------
# camke1 使用非模板类sophus
# cmake version
cmake_minimum_required(VERSION 2.8)
# project name
project(test)
find_package(Sophus REQUIRED)
include_directories(${Sophus_INCLUDE_DIRS})
...
target_link_libraries(test
${Sophus_LIBS}
)
# camke2 使用模板类sophus
cmake_minimum_required(VERSION 2.8)
set(Sophus_DIR "/usr/local/sophus-template/share/sophus/")
# project name
project(test)
find_package(Sophus REQUIRED)
include_directories(${Sophus_INCLUDE_DIRS})
...
target_link_libraries(test
${Sophus_LIBS}
)
额外安装fmt
cmake 添加
find_package(fmt)
target_link_libraries(useSophus fmt::fmt)
单纯模板类版本的引用
CMakeLists.txt
# cmake needs this line cmake_minimum_required(VERSION 3.1) # Define project name project(sophus_example_project) find_package(Sophus REQUIRED ) message("Sophus dir ${Sophus_INCLUDE_DIRS}") message("Sophus lib ${Sophus_LIBRARIES}") include_directories(${Sophus_INCLUDE_DIRS}) add_executable(useSophus example.cpp) target_link_libraries(useSophus ${Sophus_LIBRARIES})
example.cpp
#include <iostream> #include <cmath> using namespace std; #include "sophus/so3.h" #include "sophus/se3.h" int main(int argc, char** argv) { }
工程使用
mkdir build cd build cmake .. make ./useSophus
标签:cmake,make,配置,Sophus,sophus,include,camke,模板 来源: https://www.cnblogs.com/gooutlook/p/14831963.html