Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to include Eigen in a CMakeLists.txt file

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article focuses on "how to include Eigen in CMakeLists.txt files". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to include Eigen in a CMakeLists.txt file.

First of all, Eigen only has a header file (headers only), and you only need to set an include path. There are the following methods:

1. Find_package () find_package (Eigen3 REQUIRED)

Using this method automatically looks for Eigen in the cmake path of the system and in the inclusion path of the cmake set in the previous file.

LIST (APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR} /.. / cmake_modules)

You can add a specified path to the list of CMAKE_MODULE_PATH through the LIST command

two。 Set the include path

If find_package () cannot find the Eigen version you specified, or if you want to switch versions at will, you only need to set the inclusion path of the EIgen.

It should be noted that the included path is: EIGEN3_INCLUDE_DIR

Therefore, the settings that include the path are as follows:

SET (EIGEN3_INCLUDE_DIR "$ENV {EIGEN3_INCLUDE_DIR}") # set to include the path IF (NOT EIGEN3_INCLUDE_DIR) # add prompt MESSAGE (FATAL_ERROR "Please point the environment variable EIGEN3_INCLUDE_DIR to the include directory of your Eigen3 installation.") ENDIF () INCLUDE_DIRECTORIES ("${EIGEN3_INCLUDE_DIR}") # to include this path in the include path of Project

3. EIGEN_INCLUDE_DIRS and EIGEN_INCLUDE_DIR

There is a problem here. When writing the include path, I accidentally made a mistake and added an S, so the include path did not succeed; a simple test is as follows, add it to the CmakeLIsts.txt file

Set (EIGEN_INCLUDE_DIRS "/ usr/local/include/include/eigen3") message (${EIGEN_INCLUDE_DIRS})

There will not be any output. If so, other libraries may set the include path of eigen. For example, when there is a PCL library, if you use find_package (PCL 1.9 REQUIRED) to find the PCL library, and then print the inclusion path of eigen, it will print out

/ usr/include/eigen3

This is because the inclusion path of EIgen is set in PCL. Use message (${PCL_INCLUDE_DIRS}) to print out the inclusion path of PCL as follows:

/ usr/local/pcl1.10/include/pcl-1.9/usr/include/eigen3/usr/include/usr/include/pcl-1.9/usr/include/ni/usr/include/vtk-6.2/usr/include/freetype2/usr/include/x86_64-linux-gnu/freetype2/usr/include/x86_64-linux-gnu/usr/include/jsoncpp

But if it is set to

Set (EIGEN_INCLUDE_DIR "/ usr/local/include/include/eigen3")

It can be set to be successful.

At this point, I believe you have a deeper understanding of "how to include Eigen in CMakeLists.txt files". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report