Fix "error while loading shared libraries *:No such file or directory"

It happens many time when you are trying to execute some command an error pops out like
the one shown below
error while loading shared libraries: cannot open shared object file: No such file or directory

It happened to me when I was working on HP-UX machine but it can happen in any Linux machine as well. I had to search alot to overcome this issue but finally i got one solution which I will upload here.

It is not related with this particular library file. This is something with defining the shared library path variable.

These are the steps you need to follow to fix this issue:

In Linux/Unix machine

# find / -name "library file name" -type f

# find -name -type f

So now once you get the location of the directory


This command is session dependent so if you change the terminal or session again you might face the same issue so it is better to make permanent changes.

# vi /root/.bash_profile
#. /root/.bash_profile

This will update your machine with the new variables as defined in .bash_profile

Now what if you DON'T get any match for that library file in your machine. In that case you will have to download the rpm file responsible for the installation of that library file.

NOTE: This command is tested on RedHat and CentOS

Here is what you need to do

# yum whatprovides
libacl-devel-2.2.49-6.el6.i686 : Access control list static libraries and
: headers
Repo : base
Matched from:
Filename : /usr/lib/
Filename :

Now once you find the rpm file you can install it in your machine using yum

# yum -y install libacl-devel

In HP-UX machine

You need to follow the same step except for the shared library location where you will save the path

# export SHLIB_PATH=/usr/lib:$SHLIB_PATH
Update the same in your .bash_profile for making permanent changes.

Leave a Comment