I just copy the Eigen folder to /usr/local/include according to this post, to use Eigen library.

Now to compile a simple example it needs to compile with sudo:

simple1.cpp:2:23: fatal error: /usr/local/include/Eigen/Dense: Permission denied

What's wrong? I think it should not ask for permission. Can I fix it?


I also changed the permission of folder to drwxr-xr-x and added

export LD_LIBRARY_PATH="/usr/local/include/Eigen/"

and log out once. Still, I need permission to compile.

namei -lx /usr/local/include/Eigen/Dense
f: /usr/local/include/Eigen/Dense
Drwxr-xr-x root root /
drwxr-xr-x root root usr
drwxr-xr-x root root local
drwxr-xr-x root root include
drwxr-xr-x root root Eigen
-rw-r--r-- root root Dense
  • Add the output of namei -lx /usr/local/include/Eigen/Dense, please
    – muru
    May 6 '17 at 8:21
  • You say you tried to compile with sudo. What was the command used?
    – muru
    May 6 '17 at 8:30
  • g++ filename.cpp ask me permission but sudo g++ filename.cpp worked.
    – Abolfazl
    May 6 '17 at 8:36
  • Maybe I put the header files in another directory that need not permission ,give the address by -I : g++ file.cpp -I /to/library/address.
    – Abolfazl
    May 6 '17 at 8:40
  • What version of Ubuntu are you using? It looks like eigen3.3 is already available direct from the repository File list of package libeigen3-dev in xenial - there should be no need to manually copy files to /usr/local. FYI the LD_LIBRARY_PATH variable has nothing to do with header file locations. May 6 '17 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.