3

I am using Eigen3 with spectra (https://spectralib.org/), a library built on top of Eigen. Spectra uses find_package to find Eigen, and comes up with the error:

 Could not find a package configuration file provided by "Eigen3" with any
  of the following names:

    Eigen3Config.cmake
    eigen3-config.cmake

Looking through the directory of Eigen, I found that there were no files by those names, but rather one called Eigen3Config.cmake.in. I tried copying the file and renaming it Eigen3Config.cmake, but that gave me a different error of

find_package Error reading CMake code from "C:/Program Files
  (x86)/Eigen3/cmake/Eigen3Config.cmake".

which was somewhat expected, but it does tell me that it can at least find the directory where Eigen3Config.cmake.in is. I'm assuming that either find_package is supposed to use Eigen3Config.cmake.in, or Eigen3Config.cmake.in is supposed to generate Eigen3Config.cmake, but i'm very new to cmake, so i'm not sure. How do I fix this?

JylesDigiorno
  • 45
  • 1
  • 4
  • "I found that there were no files by those names, but rather one called Eigen3Config.cmake.in." - That mean you didn't **install** Eigen3. Do that, and in installation directory there will be `Eigen3Config.cmake` file, which could be found by `find_package`. – Tsyvarev May 13 '20 at 15:36
  • 2
    it says at https://eigen.tuxfamily.org/dox/GettingStarted.html#title0 that all you have to do to install is to download and extract it – JylesDigiorno May 13 '20 at 15:58
  • Yes, if you want to use Eigen3 headers by setting include directory manually, then no installation is required. But for `find_package(Eigen3)` to work you still need to install Eigen3 project. – Tsyvarev May 13 '20 at 16:15
  • 2
    ah. How exactly does one install it? All I can find from google is extraction, and I couldn't find any files in the directory that popped out at me to run. – JylesDigiorno May 13 '20 at 16:48
  • Eigen3 can be built and installed with CMake. As you use CMake for building spectra, you should be able to install Eigen3 easily. – Tsyvarev May 13 '20 at 17:47

2 Answers2

1

There is no need to build/install Eigen to use it if you include it manually, as done in the getting started example (https://eigen.tuxfamily.org/dox/GettingStarted.html#title0)

But in order to be found by CMake, you will need to build / install it, as explained in the INSTALL file. https://gitlab.com/libeigen/eigen/-/blob/master/INSTALL

Usually, your error is followed by an hint asking you to set the variable Eigen3_DIR (or something similar) to point the build/install dir of the target project (Eigen3 here). It appears typically when you have built but not installed the project.

So:

  1. Build Eigen
  2. Install it (optional)
  3. For spectra set the cmake var Eigen3_DIR to /path/to/Eigen/build . (if eigen not install or still not found)
Nico Vuaille
  • 2,310
  • 1
  • 6
  • 14
0

These steps worked for me:

  1. Install Eigen
  2. Create a build directory for Eigen
  3. cd into the build directory created
  4. run "cmake ../"Your Eigen Source Directory""

After this is done, in your CMakeLists.txt of your project, you'll want to add "find_package( Eigen3 REQUIRED)" and "include_directories( ${EIGEN3_INCLUDE_DIR})".

levente.nas
  • 83
  • 2
  • 10