fatal error: Eigen/Dense: No such file or directory

前端 未结 6 1643
说谎
说谎 2020-12-13 19:18

I have installed libeigen3-dev in order to compile programs using Eigen 3. when I include a file, such as Eigen/Dense I get this error when I try t

相关标签:
6条回答
  • 2020-12-13 19:46

    Run your compiler with the --verbose switch:

    g++ --verbose ...
    

    If your includes are relative to one of the paths shown in this output, you don't have to use -I. It depends how gcc has been configured, and it depends where that other stuff is installed.

    Note that . is typically not in the -I paths.

    Later

    After exchanging a couple of comments it is clear that /usr/include/eigen3/Eigen/Dense should be include-able by #include <Eigen/Dense>, but not by #include <eigen3/Eigen/Dense>. Therefore, the addition of the command line option -I /usr/include/eigen3 is mandatory.

    Whether some installation selects to install header files into a directory that in one of the ones compiled into gcc, depends on the default, a decision made by the distributor, or a decision made during installation. I'd say that "frequently used" header files (Boost) are well placed into /usr/local/include while some "elitist" stuff would be better off in a directory of its own.

    0 讨论(0)
  • 2020-12-13 19:48

    This worked for me (using Macports for installing Shogun on Mac OS 10.11):

    cd ${macports_prefix}/include
    sudo ln -sf eigen3/Eigen Eigen
    sudo ln -sf eigen3/unsupported unsupported
    
    0 讨论(0)
  • 2020-12-13 19:56

    Change

    #include <Eigen/Dense>
    

    to

    #include <eigen3/Eigen/Dense>
    
    0 讨论(0)
  • 2020-12-13 20:02

    If you follow the getting started instructions at the main Eigen site then you can't go far wrong.

    To surmise, download then extract the Eigen source code into a directory of choice. Next copy the "Eigen" directory into /usr/local/include/. NOTE this is the directory named "Eigen" WITHIN the directory structure extracted, NOT the entire directory structure itself. It worked for me on an Ubuntu 14.04 virtual machine.

    0 讨论(0)
  • 2020-12-13 20:05

    I had this same problem on my Ubuntu 14 box. Ended up creating symlinks to get around it. With eigen3 installed in /usr/local/include do the following:

    cd /usr/local/include
    sudo ln -sf eigen3/Eigen Eigen
    sudo ln -sf eigen3/unsupported unsupported
    

    You should now be able to include the headers by:

    #include <Eigen/Dense>
    #include <unsupported/Eigen/FFT>
    
    0 讨论(0)
  • 2020-12-13 20:07

    Should use the following:

    #if defined __GNUC__ || defined __APPLE__
    #include <Eigen/Dense>
    #else
    #include <eigen3/Eigen/Dense>
    #endif
    
    0 讨论(0)
提交回复
热议问题