24

I am using Ubuntu 14.04 and I want to install eigen 3.3 in the Ubuntu. I tried to download newest version of Eigen 3 (3.3) and install as following

mkdir build
cd build
cmake ..
make
sudo make install 

The output likes

-- Installing: /usr/local/include/eigen3/unsupported/Eigen/src/Skyline/SkylineStorage.h
-- Installing: /usr/local/include/eigen3/unsupported/Eigen/src/SparseExtra/RandomSetter.h
-- Installing: /usr/local/include/eigen3/unsupported/Eigen/src/SparseExtra/MarketIO.h
-- Installing: /usr/local/include/eigen3/unsupported/Eigen/src/SparseExtra/BlockOfDynamicSparseMatrix.h
-- Installing: /usr/local/include/eigen3/unsupported/Eigen/src/SparseExtra/DynamicSparseMatrix.h
-- Installing: /usr/local/include/eigen3/unsupported/Eigen/src/SparseExtra/MatrixMarketIterator.h
-- Installing: /usr/local/include/eigen3/unsupported/Eigen/src/Splines/SplineFwd.h
-- Installing: /usr/local/include/eigen3/unsupported/Eigen/src/Splines/SplineFitting.h
-- Installing: /usr/local/include/eigen3/unsupported/Eigen/src/Splines/Spline.h

However, when I check the my current eigen version with dpkg -p libeigen3-dev, the output is

Package: libeigen3-dev
Priority: extra
Section: libdevel
Installed-Size: 3729
Maintainer: Ubuntu Developers <[email protected]>
Architecture: all
Source: eigen3
Version: 3.2.0-8
Provides: libeigen2-dev
Depends: pkg-config
Suggests: libeigen3-doc, libmrpt-dev
Size: 494158

It shown my setup does not finish. How can I install the eigen version in my Ubuntu? Thank all

This is error when I compile with CmakeList.txt at source code

-- ===============================================================
-- ============ Configuring CompileSettings  =====================
-- ===============================================================
-- ============= Look for required libraries =====================
-- Looking for Eigen Library with minimum version 3.2.90
-- Looking for Eigen via User Provided (or Cached) location
-- Eigen version 3.2.0 found in /usr/include/eigen3
CMake Warning at cmake/FindEigen.cmake:62 (message):
  Eigen version is less than requred version 3.2.90
Call Stack (most recent call first):
  cmake/FindEigen.cmake:73 (Eigen_Check_Version)
  CMakeLists.txt:23 (FIND_PACKAGE)


CMake Error at /usr/local/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
  Could NOT find Eigen (missing: EIGEN_VERSION_OK) (Required is at least
  version "3.2.90")
Call Stack (most recent call first):
  /usr/local/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
  cmake/FindEigen.cmake:74 (find_package_handle_standard_args)
  CMakeLists.txt:23 (FIND_PACKAGE)
4
  • 1
    Unless you take additional steps (such as using the checkinstall program in place of make install), the dpkg system will know nothing about programs installed from source in this way. Dec 13, 2016 at 12:20
  • Sorry. What does it mean? How could I fix my issue. I surely that I did not install 3.3 version successfully
    – John
    Dec 13, 2016 at 12:23
  • What makes you think it was unsuccessful? What does pkg-config --modversion eigen3 say? What version do you actually get when you try to build stuff? Dec 13, 2016 at 12:29
  • Because I run a source code which require the version of Eigen >=3.2.90 and it shown that my current version is still 3.2.0
    – John
    Dec 13, 2016 at 12:37

4 Answers 4

42

For those simply requiring a reasonably recent version of Eigen 3 on Ubuntu and similar Debian-based distros (...which is the common case), installing the existing libeigen3-dev package suffices: e.g.,

sudo apt install libeigen3-dev

Manually downloading and installing Eigen 3 is probably overkill for most use cases.

3
  • 3
    Seems simple but failed for me :(
    – Yair Daon
    Jul 25, 2017 at 3:11
  • 7
    libeigen3-dev installs Eigen 3.2, he is asking for 3.3, so this answer is wrong if you need 3.3. May 8, 2018 at 17:16
  • 1
    on Ubuntu 19.04 the package gives you 3.3.7 ... whereas when you install from src tree github.com/PX4/eigen you get 3.3.90 as of 20190712 Jul 12, 2019 at 16:04
18
+50

Eigen c++ is a header only library: you don't have to install it, you just download it, unzip it and link your code against it.

For example, if your code is in my_favorite_cpp_folder, you do:

cd my_favorite_cpp_folder

and, assuming your compiler is gcc and the eigen headers are in /usr/local/include/eigen3/unsupported/ and the name of your source file is my_favorite_cpp_source_file.cpp, you compile and code and link it to the eigen headers by doing:

g++ -I /usr/local/include/eigen3/ my_favorite_cpp_source_file.cpp -o my_favorite_cpp_source_file

(from your code output posted above, the eigen headers are in /usr/local/include/eigen3/ in your computer)

10
  • Thank you. However, I compile an open source code from cmake. It use the line to check Eigen 3 version # Add Eigen dependencies FIND_PACKAGE(Eigen 3.2.90 REQUIRED). I did not find any setting lib path in the CmakeList.txt
    – John
    Dec 23, 2016 at 2:09
  • in any case your problem is not with installing eigen, it is with installing that open source library. You should put up the errors messages you get when installing that library in your question, those will be informative.
    – user2413
    Dec 23, 2016 at 9:36
  • Yes. I updated the error and source link
    – John
    Dec 23, 2016 at 12:22
  • do gedit /usr/local/include/eigen3/Eigen/src/Core/util/Macros.h look for the lines #define EIGEN_WORLD_VERSION to #define EIGEN_MINOR_VERSION copy and post those.
    – user2413
    Dec 23, 2016 at 12:40
  • 2
    Thanks. It worked now. My installed software just a project.
    – John
    Dec 23, 2016 at 14:20
3

After extracting the compressed folder check the INSTALL file. I used the second option of installing using cmake. After which "eigen3" folder with the header files was created in /usr/local/include/ folder.

In your project you can include eigen headers like this:

#include <eigen3/Eigen/Dense>

I forgot to mention this. Since the header files are in /usr/local/include/ folder you don't need to compile your source-code files against them using "g++ -I .... ."

Good luck!

2

dpkg only knows about software that you have installed by Ubuntu's standard package management tools. But that's not how you installed eigen. You have installed from the source code, and as such dpkg doesn't know it. The output of dpkg -p libeigen3-dev is not about the eigen that you installed, but about a different version of eigen, installed using the standard package management tools.

Based on your output of sudo make install, the version of eigen that you installed from source is ready to use, its files are available in /usr/local/include/eigen3/unsupported/Eigen/src.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .