Ubuntu – Setting LD_LIBRARY_PATH

pathsetUbuntu

I am trying to run a program in a server with Linux Ubuntu 3.16.0-31-generic and it gives me the following error:

error while loading shared libraries: libmpich.so.3: cannot open shared object file: No such file or directory

I have searched through the internet to find a solution, and I see people talking about setting the LD_LIBRARY_PATH somehow. Most of the ways to do it required sudo, but I don't have administrator permission, so I cannot use it.

Would this indeed this solve the problem? And if yes, how could I set it?

Best Answer

You shouldn't need permission to set this ENV (see the section on 'environment variables') variable.

And because the shared object is missing when running vs. installing an application, you shouldn't need to set this at all. You are missing a package that includes libmpich.so. Seek out and install anything from your "deb" package repository that includes the libmpich.so shared object(s). Try the following to find it/them.

$ apt-cache search mpich

Now back to the question;

There are a few ways to accomplish this. Set it yourself for the entire session, set it permanently, or tell the compiler only during compile time.

The quickest and least intrusive (regarding changing OS environment variables) is to set it for the compile procedure:

$ LD_LIBRARY_PATH=/lib:/lib64:/usr/lib:/usr/lib64 run-binary-command

Or you can set it for the current session like so:

$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib:/lib64:/usr/lib:/usr/lib64

And to set it forever:

$ echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib:/lib64:/usr/lib:/usr/lib64' >> ~/.profile
Related Question