C/C++教程

【Ubuntu18.04】【外部项目CMakeLists编写】非模版类Sophus安装

本文主要是介绍【Ubuntu18.04】【外部项目CMakeLists编写】非模版类Sophus安装,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

为什么选择非模版类

因为模版类安装报错。。 找不到解决办法。。你们是怎么安装那么顺利的。。

Sophus安装

git clone https://github.com/strasdat/Sophus.git
cd Sophus/
git checkout a621ff
mkdir build
cd build
cmake ..
make
sudo make install

外部项目CMakeLists编写

-workspace
	-CMakeLists.txt
	-bin
	-build
	-include
	-src
		main.cpp

CMakeLists.txt文件编写

cmake_minimum_required(VERSION 3.0)
project(workspace)

set(CMAKE_CXX_FLAGS "-std=c++11")
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(Sophus_DIR "/home/usrname/Sophus/build")
find_package(Sophus REQUIRED)

AUX_SOURCE_DIRECTORY(src DIR_SRCS)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(TEST_VIO ${DIR_SRCS})
set(Sophus_LIBRARIES "/usr/local/lib/libSophus.so")
include_directories(${workspace_vioslam}/include)
include_directories(${Sophus_INCLUDE_DIRS})
include_directories("/usr/include/eigen3")
add_executable(run ${TEST_VIO})

target_link_libraries(run ${Sophus_LIBRARIES})

编好CMakeLists.txt之后
编译:

//从workspace根目录下
cd build
cmake ..
make

运行:

//从workspace根目录下
cd bin
./run
这篇关于【Ubuntu18.04】【外部项目CMakeLists编写】非模版类Sophus安装的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!