Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
11
rated 0 times [  11] [ 0]  / answers: 1 / hits: 42609  / 3 Years ago, thu, may 27, 2021, 7:31:09

I am trying to install eigen, but I don't seem to get it to work.



I did:



sudo apt-get install libeigen3-dev


and everything seems fine, after



dpkg -p libeigen3-dev


I get:



Package: libeigen3-dev
Priority: extra
Section: libdevel
Installed-Size: 3718
Maintainer: Ubuntu Developers <[email protected]>
Architecture: all
Source: eigen3
Version: 3.2.0-4
Depends: pkg-config
Suggests: libeigen3-doc
Size: 698062
Description: lightweight C++ template library for linear algebra
Eigen 3 is a lightweight C++ template library for vector and matrix math,
a.k.a. linear algebra.
.
Unlike most other linear algebra libraries, Eigen 3 focuses on the simple
mathematical needs of applications: games and other OpenGL apps, spreadsheets
and other office apps, etc. Eigen 3 is dedicated to providing optimal speed
with GCC. A lot of improvements since 2-nd version of Eigen.
Original-Maintainer: Debian Science Maintainers <[email protected]>
Homepage: http://eigen.tuxfamily.org


Everything looked fine to me. However, when I try to compile the basic code (given in the tutorial):



first_eigen.cpp



#include <iostream>
#include <Eigen/Dense>
using namespace Eigen;
int main()
{
Matrix2d a;
a << 1, 2,
3, 4;
MatrixXd b(2,2);
b << 2, 3,
1, 4;
std::cout << "a + b =
" << a + b << std::endl;
std::cout << "a - b =
" << a - b << std::endl;
std::cout << "Doing a += b;" << std::endl;
a += b;
std::cout << "Now a =
" << a << std::endl;
Vector3d v(1,2,3);
Vector3d w(1,0,0);
std::cout << "-v + w - v =
" << -v + w - v << std::endl;
}


I run it in the shell like this:



g++ -std=c++11 first_eigen.cpp -o my_exec


I get the following error:



first_eigen.cpp:2:23: fatal error: Eigen/Dense: No such file or directory
#include <Eigen/Dense>
^
compilation terminated.


So it looks like eigen was not installed. What am I missing?


More From » 13.10

 Answers
3

The eigen3 header files go in a subdirectory /usr/include/eigen3 e.g.



/usr/include/eigen3/Eigen/Array
/usr/include/eigen3/Eigen/Cholesky
/usr/include/eigen3/Eigen/CholmodSupport
/usr/include/eigen3/Eigen/Core
/usr/include/eigen3/Eigen/Dense
/usr/include/eigen3/Eigen/Eigen


so you will need to specify the additional include path on your compiler command line, for example



g++ -std=c++11 -I/usr/include/eigen3 first_eigen.cpp -o my_exec


Alternatively (and possibly more portably), you can use the pkg-config database to automate the inclusion, i.e.



g++ -std=c++11 `pkg-config --cflags eigen3` first_eigen.cpp -o my_exec

[#24312] Saturday, May 29, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
epypian

Total Points: 130
Total Questions: 111
Total Answers: 113

Location: Romania
Member since Mon, Jun 6, 2022
2 Years ago
epypian questions
Sat, Jul 31, 21, 18:35, 3 Years ago
Sun, Oct 24, 21, 23:28, 3 Years ago
Sun, Dec 26, 21, 12:08, 2 Years ago
Tue, May 9, 23, 21:23, 1 Year ago
;