Shared Libraries

This question has probably asked many times, but it seems that a lot of times when I download software and try to install it I get error messages saying that shared libaries are missing.  I see things like:

How do I find out where my shared libraries are located on my system and what versions I have?  Also, once I get any newer libraries from the net, what folders should they reside in, so the new program can find them?

Thanks for the help, I hope maybe someone can explain this to me.

Who is Participating?
kiffneyConnect With a Mentor Commented:
It's not easy to upgrade libraries.  I've done it myself, made mistakes, and been unable to boot my system.  You learn a lot that way trying to recover!  Generally the rpm package manager doesn't work quite  as well on non-redhat distributions.  Check the rpm man page for 'rebuild-database' and 'force' and 'nodeps' options.  They will allow you to install  rpms without the rpm database.  I have used rpm on slackware this way with success.  It really is the way to go if you don't care to learn all this trivia about how to install software.  
My recommendation is to go to and download it, then (as root) install it with

rpm -U --force --nodeps glibc-2.1.2-11.i386.rpm

if that doesn't work, first make sure there is a /var/lib/rpm directory, then do
rpm --rebuilddb

then do the rpm install command above.

Good luck.
Normally al system libraries are present in /usr/lib.

For eg. /usr/lib/

This will be a link to the latest version of the libc installed in your machine.
For eg. If is the latest version then.
lrwxrwxrwx   1 root     root           11 Jan 22 09:05 /usr/lib/ -> ./*

If you have installed in other directories, you could use LD_LIBRARY_PATH
at run time and -L option at compile time
If you install your libraries in a non-standard directory you can use the -LDirectory option while compiling; for shared libraries the path is indicated by the environment variable LD_LIBRARY_PATH.Set this environment variable to include the non-standard directory Example : LD_LIBRARY_PATH=/usr/lib:/home/dmaroff/own_lib. You can save yourself a lot of installation grief caused by different versions oflibraries by using RPM ( RedHat Package Manager ).RPM runs on a wide variety of Unix/Linux platforms - you can find more info on RPM at and the RPM package for your favourite software package at

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

I'd also suggest you try to run ldconfig after installing new shared libraries.
Of course RPM does this four you if you are willing to stick to prepackaged versions.

dmaroffAuthor Commented:
ramaswamys:  The problem is, is that when I do use RMPs it wont install because of the missing libraries.  This also happens when I get a tarred/zipped file and I run the "configure" script that usually comes with most programs.

How Do I know what path the program is looking for libaries under?  In Windows, I know that when a DLL is missing the error messagebox usually tells you the path its expecting it to be in.

Whats the difference between lib and glib.  I know glib is the GNU version so why is the names sometimes mixed?

Thanks for helping me,
glib is not (g)libc, quote from 'rpm -qi glib':
"GLib is a handy library of utility functions. This C library is
designed to solve some portability problems and provide other useful
functionality which most programs require."

for RPM installation, you can check on rpm2html database at First locate the HTML page for the RPM you are trying to install, then click on the lib it requires and your installation complains about, it will show you which package provide that lib. back to your system to check if you have it or not:
rpm -aq|grep rpmGiveNecessaryLib
Programs don't look in hardcoded paths for libraries - they ask, the dynamic library linker, where the library is, and loads it for them. looks in something called the /etc/ for the list of installed libraries.  You can change the paths that looks in by editing /etc/, then running ldconfig -v.  ldconfig will show you all your libraries and their versions (the version number is part of the library file name).  Also, the library system depends on symbolic links - the generic version number (like is a symlink to the 'real' file, which might be, for example. It's confusing, but works well - when you upgrade a library, you just also just upgrade the link to point to your new version and your binary will still work.

Any new libraries you get should be installed either in /lib or in one of the paths listed in /etc/ (and then run ldconfig -v to update the cache).  Usually /lib has major system libraries like libc, /usr/lib has custom libraries, but really it doesn't matter as long as it's in /lib (which is searched by default) or if has the paths to the various library directories in it.

When you ask about lib and glib, you might be referring to libc and glibc.  The difference is really just a version difference.  libc5 was replaced by glibc2.  They call glibc2 '' also in the /lib directory just to be confusing, I suppose.  I think they added the g to emphasize that it is a library from gnu.  
dmaroffAuthor Commented:
Kiffney:  Things are starting to make a little more sence now.  But I went into the /etc/ and I saw peculiar first line said like this:


I didn't see a /lib as one of the lines so I added it.  When I ran ldconfig -v I noticed that it showed all the links, but it gave an error with this /lib-aout.  It said it couldnt find it.  Does that need to be there?

Also, when I ran 'ldconfig -v' it showed this as one of the libraries under /lib: =>

Is this correct?
Where does this point to?

Finally when I run the RPM -i prog
and I still get:

failed dependencies: is needed by prog is needed by prog "               " "         "

Why does, or how would, '' point to 2 different libraries?

Thanks for the help, I appreciate it.
If you cd to /lib and do 'ls -l libc*'
it SHOULD look something like this

lrwxrwxrwx 1 root root 13 Feb 2 1999 ->*

with another entry like this

-rwxr-xr-x 1 root root 3070220 Oct 13 1998

all on one line.  That is, is a LINK to  The first entry should have a small size and the real should be about 3 megabytes.  It may be that all have is the link and don't have the actual file.  If you don't actually have you need to download it (or whatever the current version is) and install it in lib, then create the link in lib by deleting the link then doing

ln -s

then run ldconfig, and your programs that need glibc should run.  

You don't need the lib-aout in /etc/ and you can delete it.  You also probably don't need /lib in there since ldconfig, I think, searches that by default, but this may not be true.
dmaroffAuthor Commented:
Thanks for your help, but it seems that using shared libraries is a science unto itself.  There are about 10,000 factors that seem to go into this thing.  I ran:
'ls -l libc' and was not linking to anything.  All I got was =>

I looked all over the net and had trouble finding any downloads. So I went to and downloaded 'glibc2.1.2' (about 8meg) and unzipped it.  I go to configure it and it tells me that I shouldn't compile until I 'linuxthreads' and 'crypt' add-ons.  It seems like there are too many dependencies and too much aggrivation to get something to work in Linux.  I cant see how people install this software.  Did I download the wrong libraries possibly?  This seems way uneccessariy complex.

dmaroffAuthor Commented:
Thanks for all your help, I'll try that. Also, Are there any good books on how to install shared libraries properly?  Because I can see that a lot of programs dont come in RPM format and your stuck, the old fashioned way.  Finally, where is a good place to download shared libraries in case I need others?

I suppose the best book on installing libraries, as well as other administrative Unix/Linux topics, would be O'Reilly's Unix in a Nutshell or Matt Welsh's Running Linux at
As far as shared libraries, really the best way is to go to the metalab link I gave you above and download the rpm and install it that way.  There are not many libraries that don't appear in that directory!  If a particular software package needs its own library, it usually comes with the package.
Another point - in rereading your post, you mentioned that when you did
rpm -i prog
you saw failed dependencies.  The libc, libm, libpthread  libraries will all be installed by the glibc package.  Then install your program

'rpm -i --force --nodeps prog' and

you're off!
dmaroffAuthor Commented:
Yea I did that, so I tried to install the libraries and they wouldn't install either.  

But once I used the 'rpm -i --force -nodeps' method, everything worked great.  What does that do exactly?
Should I use it all the time?

I don't know exactly.  I think rpm expects you have a Red Hat distribution, and expects EVERYTHING on your system to have been installed and to have an entry in the rpm database.  So if you do a

'rpm -qai'

on a RedHat system you see EVERYTHING ever installed, kernel, etc on the RedHat.  Since you don't have redhat, that rpm database has not been filled in, so it thinks you don't have a kernel, a filesystem, init, or anything.  If you know you have something, you can do force nodeps and it will work.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.