1

While setting up the Eigen library, I tried:

#include <eigen/Eigen/Dense>

Which results in the error:

eigen/Eigen/Dense: No such file or directory

However,

#include "eigen/Eigen/Dense"

succeeds.

Why is this? Based on previous questions asked, I suspect this is because #include <> searches in the system directory and #include "" searches locally. If this is true, how would one put the Eigen folder in the system directory?

  • How did you tell the compiler about the include directories? In VS if you go to properties -> VC++ Directories -> Include Directories and add it, you can use the `< >` notation. With g++ I use the -I option to do the same. – Matt Jul 29 '21 at 02:23
  • Would I be able to use -I without telling the compiler about the include directories? for example, if the header files were in a folder called `eigen` on desktop (windows), should `g++ -I /C:/Users/user/Desktop/eigen main.cpp` compile? – lostinparadise Jul 29 '21 at 02:40
  • Do the "previous questions" you looked at include [What is the difference between #include and #include “filename”?](https://stackoverflow.com/questions/21593/what-is-the-difference-between-include-filename-and-include-filename/21594#21594) *Note: Even though nominally directed at the OP, this comment is also for the benefit of future readers.* – JaMiT Jul 29 '21 at 02:55

1 Answers1

0

You will need to follow the instructions that are specific for your operating system. You did not describe your operating system and compiler, and this is something for which no standard instructions apply for every operating system used in the world today. It varies by operating system and compiler.

Alternatively, all C++ compilers have a configuration setting that adds an additional directory to the list the compiler looks when searching for #include <path> header files. gcc, and many other Linux compilers use the -I option. This can be specified manually, or in a Makefile.

MS-Windows compilers have a specific settings too. This Stackoverflow question provides instructions for several versions of the Visual Studio IDE.

Sam Varshavchik
  • 114,536
  • 5
  • 94
  • 148