c++ - 使用 Ceres 求解器进行 CMake 项目时的 Eigen 依赖项冲突
问题描述
我安装ceres-solver
使用
brew install ceres-solver
在 macOS 上。
CMake.txt
我为使用 Ceres 的客户项目创建了一个。
cmake_minimum_required(VERSION 2.8)
project(helloworld)
find_package(Ceres REQUIRED)
include_directories(${CERES_INCLUDE_DIRS})
# helloworld
add_executable(helloworld helloworld.cpp)
target_link_libraries(helloworld ${CERES_LIBRARIES})
但是,当我运行以下命令时
cmake . -Bbuild
我收到以下错误
CMake Error at /usr/local/lib/cmake/Ceres/CeresConfig.cmake:88 (message):
Failed to find Ceres - Found Eigen dependency, but the version of Eigen
found (3.3.90) does not exactly match the version of Eigen Ceres was
compiled with (3.3.7). This can cause subtle bugs by triggering violations
of the One Definition Rule. See the Wikipedia article
http://en.wikipedia.org/wiki/One_Definition_Rule for more details
Call Stack (most recent call first):
/usr/local/lib/cmake/Ceres/CeresConfig.cmake:223 (ceres_report_not_found)
CMakeLists.txt:5 (find_package)
CMake Error at CMakeLists.txt:5 (find_package):
Found package configuration file:
/usr/local/lib/cmake/Ceres/CeresConfig.cmake
but it set Ceres_FOUND to FALSE so package "Ceres" is considered to be NOT
FOUND.
-- Configuring incomplete, errors occurred!
如何删除 Eigen 的冲突版本?我不记得我过去是如何安装它的。我也尝试过运行brew uninstall Eigen
,但这并没有使错误消失。
谢谢你的帮助。
解决方案
因此,Ceres 是使用 Eigen 3.3.7 构建的,但您的 helloworld 构建正在寻找 Eigen 3.3.90。我发现跟踪此类 cmake 问题的最佳方法是在运行 cmake 配置步骤时使用--trace-expand
and选项。--debug-output
它会生成大量输出,因此将其全部重定向到一个文件,然后搜索 find_package eigen 语句。例如
cmake . -Bbuild --debug-output --trace-expand > cmake.out 2>&1
推荐阅读
- python - SQLAlchemy IntegrityError:但是哪些记录?
- python - 如何在“if”循环中使用我的列表?
- javascript - 检查多个对象数组的项
- react-native - 如何在 React Native 中缓存视频
- c# - 了解 ADO.NET 的“连接生命周期”
- java - 无法使用 spring kafka 生产者向 Kafka 发送任何消息 - 超时异常
- sql - Redshift 中的溢出错误
- excel - 宏 Excel:检查单元格是否为空
- javascript - 承诺功能无法识别外部变量
- rust - 为什么 Rust 找不到 wl_display_get_registry?