redhat error while loading shared libraries

If you get an shared library loading error similar to the following when trying to run an application its probably due to RedHat not including the /usr/local/lib shared library directory by default or the directory your application has its shared library installed.

Show Plain Text
Text code
  1. /usr/local/bin/dumprecs: error while loading shared libraries: libxbase-2.0.so.0: cannot open shared object file: No such file or directory

A good way to see which other shared libraries aren't being loaded by your executable is by using the ldd command :-

Show Plain Text
Text code
  1. ldd <fullpath to binary>

To add a shared library path you can use the ldconfig command, for example if your libraries are installed in say the /usr/local/lib (which again is not included by default under RedHat) you can add the path as follows :-

Show Plain Text
Text code
  1. echo "/usr/local/lib" >> /etc/ld.so.conf
  2. ldconfig

Or you can add a conf file to the /etc/ld.so.conf.d directory with the library lines to be included, for example in a 64 bit environment you would add to the file /etc/ld.so.conf.d/mylibs.conf :-

Show Plain Text
Text code
  1. /usr/local/lib
  2. /usr/local/lib64

Make sure you run the ldconfig command to re-load the shared library cache, you can view all the library files the ldconfig has with the following command :-

Show Plain Text
Text code
  1. ldconfig -p | less

All in all a fairly simple quick to fix.

Filed under: Linux  Tags: Redhat, Debian, Ubuntu

1 Responses to “redhat error while loading shared libraries”

Great!! thanks i need to install dependencies for ftp rpm i have. but still getting error as below .. can u plz help. I am using redhat 2.6.32-131.0.15.el6.i686 [root@pdrive sert]# ldconfig ldconfig: /usr/local/lib/libreadline.so.4 is not an ELF file - it has the wrong magic bytes at the start. ldconfig: /sert/libreadline.so.4 is not an ELF file - it has the wrong magic bytes at the start. [root@pdrive sert]# ldd /sert/libreadline.so.4 not a dynamic executable

Sorry, comments have been closed for this post.