lenignes
lenignes

Reputation: 333

How do I compile C++ file using the Eigen Library?

I'm currently following this Eigen: Getting Started to try to compile my C++ file using the Eigen Library but I'm running into a bunch of errors. My current directory contains my main.cpp, network.h and the Eigen Library which contains a directory called Eigen and a bunch of other folders. The guide says to just put in the path to folder, containing the header files. I'm currently using g++ -I eigenLibrary/Eigen main.cpp -o network to compile, but I keep getting the error fatal error: 'Eigen/Dense' file not found #include <Eigen/Dense>. I'm trying implement the code in this tutorial . How can I make sure I'm linking the libraries in the right format. I don't have much experience with C++

EDIT: I've tried copying the Eigen subdirectory into /usr/local/include and running g++ -I /usr/local/include/Eigen/Dense main.cpp -o main to no success.

Upvotes: 0

Views: 2716

Answers (3)

ggulgulia
ggulgulia

Reputation: 3080

Eigen3 headers is by default installed under /usr/include/eigen3 directories To compile a program using Eigen3

  1. a solution suggested by @Arjun Kumar could be used

  2. to save tedious typing every time during compiling, a symbolic link inside /usr/local/include can be added to point to /user/include/eigen3 be made:

    sudo ln -s /usr/include/eigen3/Eigen /usr/local/include/Eigen
    

and then compile the program without any flags like:

    g++ -std=c++11  fileName.cpp

Upvotes: 0

Arjun Kumar
Arjun Kumar

Reputation: 173

Please include the Eigen library path as follows:

g++ -std=c++11 -I /usr/include/eigen3/ fileName.cpp

Upvotes: 2

Larry Gillstrom
Larry Gillstrom

Reputation: 25

Try -I eigenLibrary instead of -I eigenLibrary/Eigen in your command line

Upvotes: 0

Related Questions