CMake 查找特征不正确的结果
CMake find eigen incorrect results
我正在尝试使用 CMake 编译带有Eigen
的代码片段,但 CMake 似乎很难找到正确的路径,即使源代码在那里。
这是我CMakeLists.txt
文件。
cmake_minimum_required(VERSION 3.14.2)
project(test)
# set default build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
find_package(OpenCV 3 REQUIRED)
find_package (Eigen3 3.3 REQUIRED NO_MODULE)
include_directories(
include
${OpenCV_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
)
add_executable(playground playground.cpp)
target_link_libraries(playground ${OpenCV_LIBS} Eigen3::Eigen)
这就是我在playground.cpp
中导入标头的方式:
#include <iostream>
#include <vector>
#include <map>
#include <math.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <string>
#include <Eigen>
我的Eigen
安装在/usr/include/eigen3
下,这是目录结构:
yuqiong@yuqiong-G7-7588:/usr/include/eigen3$ ls
Eigen signature_of_eigen3_matrix_library unsupported
所以通往特征库的正确路径是/usr/include/eigen3/Eigen
。
但是,当我运行cmake ..
然后make
上述CMakeLists.txt
文件时,带有-LH
标志,CMake 抱怨它找不到Eigen
。这是它认为Eigen
所在的路径:
yuqiong@yuqiong-G7-7588:/media/yuqiong/DATA/vignetting/catkin_ws/src/vig2/src/build$ cmake -LH ..
-- Configuring done
-- Generating done
-- Build files have been written to: /media/yuqiong/DATA/vignetting/catkin_ws/src/vig2/src/build
-- Cache values
// Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel ...
CMAKE_BUILD_TYPE:STRING=
// Install path prefix, prepended onto install directories.
CMAKE_INSTALL_PREFIX:PATH=/usr/local
// The directory containing a CMake configuration file for Eigen3.
Eigen3_DIR:PATH=/usr/local/share/eigen3/cmake
// The directory containing a CMake configuration file for OpenCV.
OpenCV_DIR:PATH=/opt/ros/kinetic/share/OpenCV-3.3.1-dev
这是它认为 Eigen 所在的文件夹的结构:
yuqiong@yuqiong-G7-7588:/usr/local/share/eigen3$ tree
.
└── cmake
├── Eigen3Config.cmake
├── Eigen3ConfigVersion.cmake
├── Eigen3Targets.cmake
└── UseEigen3.cmake
我很困惑为什么CMake会有这样的行为?在这种情况下,我怎样才能让它找到正确的Eigen
路径?
所有这些环境设置都非常棘手,无法正确处理......
感谢您上面的评论。我认为问题可能是Eigen
团队在不同版本之间以某种方式更改了目录结构,并且旧的包含路径不再起作用。
我的解决方案是将#include <Eigen/Dense>
更改为#include <eigen3/Eigen/Dense>
。之后,g++
和CMake
可以找到路径。
我确实按照这个官方文档安装了Eigen
,这就是为什么我对安装仍然有问题感到惊讶的原因。
这个答案解决了我的问题。
这个答案也解决了问题。
另一方面,我的CMake文件有点混乱,既有include_directories
又有target_link_libraries
。
相关文章:
- 密码登录程序将永远循环并显示不正确的结果
- 特征 LLT 模块给出不正确的结果?
- 计算幂级数的数学结果不正确
- wcslen() 在使用编译指示包时返回不正确的结果
- 使用动态分配的数组进行矩阵乘法;结果不正确
- CMake 查找特征不正确的结果
- 将函数的地址转换为UINTPTR_T给我不正确的结果
- 使用 C++ 中的运算符重载显示不正确的结果
- 简单的程序比较阵列运行但给出不正确的结果
- 为什么隐式类型转换在此代码中结果不正确
- 使用Boost Polygon的减法结果不正确
- 使用SSE内在时的结果不正确
- 嵌套循环语句结果不正确
- 由于 istream 中的杂散 导致 get () 的结果不正确,但 scanf() 或 cin 则不然
- 主机上运行的自定义函数的Thrust结果不正确
- 使用cblas_dgemv()计算矩阵向量乘积的结果不正确
- 数学库三角函数C++结果不正确
- GLSL -从阴影立方体图中检索值时结果不正确
- 当 T 声明 T::T(T&) 时,std::is_trivially_constructible<T、T&>::value 的结果不正确
- 对于循环数组迭代,if循环测试索引是否为真/假,计算结果不正确