CMake of common libraries in slam (how to add various dependent libraries) _ Library

Source: Internet
Author: User

LZ has previously written a slam rely on the library installation, if the installation in accordance with the previous encyclopedia installed, the subsequent compilation of their own projects need to link a variety of library files and header files, but specifically in the CMakeLists.txt how to use it. This blog is ready to compile a variety of Slam common library link methods.

1. Add Eigen header File

How do we use this dependent library after Eigen is installed through Apt-get? Eigen It's strange that the Eigen library has only header files, so we don't need to write target_link_libraries in CMakeLists.txt, because we're installed through apt, so it's easy to know where the Eigen library is in/usr/ Include/eigen3

#添加头文件
include_directories ("/usr/include/eigen3")

Because we already know eigen specific position, do not use find_package to look for, although some rough, but simple and effective.

2. Add Pangolin Dependencies
Pangolin installation is also very simple, the main function is to do three-dimensional visual display, the main dependent library is OpenGL, through apt also very good installation.

Find_package (Pangolin)

include_directories (${pangolin_include_dirs})

add_executable (project_name Filename.cpp)

target_link_libraries (Project_Name ${pangolin_libraries})

3. Add Sophus Dependencies

Sophus is actually a eigen library expansion module, eigen although there are geometric modules, but did not provide the support of Lie algebra, so Sophus is a better Lie algebra library, the installation of references before Bowen.

Find_package (Sophus REQUIRED)
include_directories (${sophus_include_dirs})
add_executable (project_name Project_name.cpp)
target_link_libraries (Project_Name ${sophus_libraries})

4. Add OpenCV dependencies
OpenCV often appear version incompatibility problem, LZ also installed OpenCV2 and OpenCV3 two versions, so in CMakeLists.txt to specify OPENCV version.

#指定OpenCV的版本是3.1
find_package (OpenCV 3.1 REQUIRED)

include_directories (${opencv_include_dirs})

add_ Executable (project_name filename.cpp)

target_link_libraries (Project_Name ${opencv_libs})

Add OpenCV to note a problem, case. Very important. Uppercase and lowercase.

5. Add PCL dependency

This point cloud Library in the Slam application is very important, usually seems to have installed, installation is very simple, here or talk about how to write CMakeLists.txt:

Find_package (PCL REQUIRED COMPONENT common io)

include_directories (${pcl_include_dirs})

Add_definitions (${ Pcl_definitions})

target_link_libraries (Project_Name ${pcl_libraries})

6. Add Ceres Dependencies

Ceres is Google's production of an optimization library, installation and compilation in the LZ before written a slam installation Daquan have. Because Ceres is not a common library, you need to add a cmake_modules. LZ here to the corresponding Cmake_modules folder in the file to share with the small partners, there is a need to download themselves. Link: http://pan.baidu.com/s/1o8dTy8i Password: ZMIV

#这行代码就是添加查找Ceres的一个文件
list (APPEND cmake_module_path ${project_source_dir}/cmake_modules)

find_package ( Ceres REQUIRED)

include_directories (${ceres_include_dirs})

target_link_libraries (Project_Name ${ceres_ Libraries})

7 Adding G2O dependencies

In fact, this is the same, the same. Here is also to pay attention to a few problems, the first, to be in Cmake_module if Findg2o file, Link: http://pan.baidu.com/s/1kVp4Ul5 password: yeu4, and the need for small partners can download themselves. Second, note the case, and the number 0 and the letter 0, this is still to be noted.

List (APPEND cmake_module_path ${project_source_dir}/cmake_modules)

find_package (g2o REQUIRED)

Include_ Directories (${g20_include_dirs})

target_link_libraries (project_name g2o_core g2o_stuff)

Slam dependent libraries have a lot of, and for different code to use the library is not the same, so, use one, LZ will also update a, this blog has not been continued ... O (∩_∩) o

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.