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.
(default) 11 queries took 7 ms
NrQueryErrorAffectedNum. rowsTook (ms)
1DESCRIBE `posts`17171
2DESCRIBE `comments`11111
3DESCRIBE `tags`221
4DESCRIBE `categories`221
5DESCRIBE `posts_tags`220
6DESCRIBE `categories_posts`221
7SELECT `Post`.`id`, `Post`.`url`, `Post`.`title`, `Post`.`icon`, `Post`.`metadesc`, `Post`.`metakeys`, `Post`.`categories`, `Post`.`tease`, `Post`.`body`, `Post`.`private_body`, `Post`.`created`, `Post`.`modified`, `Post`.`status`, `Post`.`allow_comments`, `Post`.`tags`, `Post`.`hitcount`, `Post`.`hitcount_rss` FROM `posts` AS `Post` WHERE `Post`.`url` = 'redhat-error-while-loading-shared-libraries' LIMIT 1110
8SELECT `Comment`.`id`, `Comment`.`post_id`, `Comment`.`body`, `Comment`.`author`, `Comment`.`url`, `Comment`.`email`, `Comment`.`ip`, `Comment`.`status`, `Comment`.`junk_score`, `Comment`.`created`, `Comment`.`modified` FROM `comments` AS `Comment` WHERE `Comment`.`status` = 2 AND `Comment`.`post_id` = (74) 111
9SELECT `Tag`.`id`, `Tag`.`tag`, `PostsTag`.`post_id`, `PostsTag`.`tag_id` FROM `tags` AS `Tag` JOIN `posts_tags` AS `PostsTag` ON (`PostsTag`.`post_id` = 74 AND `PostsTag`.`tag_id` = `Tag`.`id`) 330
10SELECT `Category`.`id`, `Category`.`category`, `CategoriesPost`.`post_id`, `CategoriesPost`.`category_id` FROM `categories` AS `Category` JOIN `categories_posts` AS `CategoriesPost` ON (`CategoriesPost`.`post_id` = 74 AND `CategoriesPost`.`category_id` = `Category`.`id`) 111
11UPDATE `posts` AS `Post` SET `Post`.`hitcount` = Post.hitcount + 1 WHERE `Post`.`id` = 7410