0

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.

3 Answers 3

2

Please include the Eigen library path as follows:

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

Sign up to request clarification or add additional context in comments.

Comments

0

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

5 Comments

I've tried that previously. I keep getting ./network.h:17:21: error: expected ';' at end of declaration MatrixXd weights{ MatrixXd::Zero(i, j) };
so you tried that and you got past the problem with 'Eigen/Dense' file not found #include <Eigen/Dense>?
Yeah I did. But now I'm getting an error in this line of code - MatrixXd weights{ MatrixXd::Zero(i, j) }; return weights;
I don't understand why you down voted my answer when it actually solved the question you asked...
I didn't downvote your answer. I'm not sure who did. Also, I haven't fixed my code yet. Haven't been able to fix the error i mentioned above
0

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 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.