Search code examples
opencveigeneigen3

How to include Eigen in C++ library after installing libeigen3-dev package


I am trying to build OpenCV from Source (master branch) using cmake.

I installed Eigen package via apt-get.

sudo apt-get install libeigen3-dev

It was successfully installed, and cmake prints that eigen 3.3.4 is installed.

Eigen: YES(ver 3.3.4)

But when I did 'make', it showed the error

/opencv/modules/core/include/opencv2/core/private.hpp:66.12: fatal error: Eigen/Core: No such file or directory
#  include <Eigen/Core>
           ^~~~~~~~~~~~
compilation teminated.

Solution

  • I found the same question on superuser.

    So as the answer did, I have changed cmake/OpenCVFindLibsPerf.cmake from line 44 to 59.

    After I have commented out line 46-48 and 59, and changed find_package(Eigen3 QUIET) in line 44 to find_package(Eigen3 3.0.0), it works.

    And this problem only happens on OpenCV 4.0 version.

    When I install OpenCV 3.4.6 version(tag 3.4.6 on github), this problem does not occur.