Clion / Cmake和Eigen错误 [英] Error with Clion/Cmake and Eigen

查看:244
本文介绍了Clion / Cmake和Eigen错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试启动Eigen,但遇到了障碍。我打开了Clion,并在CMakeLists.txt选项卡中输入了以下代码。请注意,我已经用自制软件安装了Eigen。

I am trying to get Eigen up and running but I am running into a roadblock. I opened Clion and in the CMakeLists.txt tab I entered the following code. Please note I have installed Eigen with home-brew.

project(untitled)

cmake_minimum_required(VERSION 3.7)

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

find_package(Eigen3 REQUIRED)

include_directories(EIGEN3_INCLUDE_DIR)

set(SRCS main.cpp)

add_executable(untitled ${SRCS})

我遇到以下错误。

/Applications/CLion.app/Contents/bin/cmake/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /Users/johnmcconnell/CLionProjects/untitled
CMake Error at CMakeLists.txt:9 (find_package):
  Found package configuration file:

    /usr/local/share/eigen3/cmake/Eigen3Config.cmake

  but it set Eigen3_FOUND to FALSE so package "Eigen3" is considered to be
  NOT FOUND.

我以前从未做过,我真的很茫然,关于如何做的任何想法?

I've never done this before and I am really at a loss, any ideas on what to do?

更新:
代码更改可以清除错误,但会产生一个新错误。

UPDATE: Change in code clears the error but yields a new one.

fatal error: 'Eigen/Dense' file not found

project(untitled)

cmake_minimum_required(VERSION 3.7)

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

include_directories(EIGEN_INCLUDE_DIR)

set(SRCS main.cpp)

add_executable(untitled ${SRCS})


推荐答案

除了@John Zwinck的答案所解决的问题之外,您的 include_directories 语句中还有一个错误。

In addition to the problem solved by @John Zwinck's answer, you have an error in your include_directories statement.

应该是

include_directories(${EIGEN3_INCLUDE_DIR})

而不是

include_directories(EIGEN_INCLUDE_DIR)

这篇关于Clion / Cmake和Eigen错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆