Shared Libraries

Posted on 2000-02-23
Medium Priority
Last Modified: 2010-04-21
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.

Question by:dmaroff

Expert Comment

ID: 2552318
Normally al system libraries are present in /usr/lib.

For eg. /usr/lib/libc.so.

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

If you have installed in other directories, you could use LD_LIBRARY_PATH
at run time and -L option at compile time

Expert Comment

ID: 2553769
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 www.rpm.org and the RPM package for your favourite software package at www.rpmfind.net


Expert Comment

ID: 2553852
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.

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 2554787
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,

Expert Comment

ID: 2559718
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 www.rpmfind.net. 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

Expert Comment

ID: 2569906
Programs don't look in hardcoded paths for libraries - they ask ld.so, the dynamic library linker, where the library is, and ld.so loads it for them.  ld.so looks in something called the /etc/ld.so.cache for the list of installed libraries.  You can change the paths that ld.so looks in by editing /etc/ld.so.conf, 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 libc.so.6) is a symlink to the 'real' file, which might be libc-2.0.7.so, 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/ld.so.conf (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 ld.so.conf 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 'libc.so.6' 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.  

Author Comment

ID: 2570658
Kiffney:  Things are starting to make a little more sence now.  But I went into the /etc/ld.so.conf 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:

libc.so.6 => libc.so.6

Is this correct?
Where does this point to?

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

failed dependencies:

libc.so.6(GLIBC_2.0) is needed by prog
libc.so.6(GLIBC_2.1) is needed by prog
libm.so.6(GLIBC_2.1) "               "
libpthread.so.0(GLIBC_2.0) "         "

Why does, or how would, 'libc.so.6' point to 2 different libraries?

Thanks for the help, I appreciate it.

Expert Comment

ID: 2571195
If you cd to /lib and do 'ls -l libc*'
it SHOULD look something like this

lrwxrwxrwx 1 root root 13 Feb 2 1999 libc.so.6 -> libc-2.0.7.so*

with another entry like this

-rwxr-xr-x 1 root root 3070220 Oct 13 1998 libc-2.0.7.so

all on one line.  That is, libc.so.6 is a LINK to libc-2.0.7.so.  The first entry should have a small size and the real libc-2.0.7.so 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 libc-2.0.7.so 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 libc-2.0.7.so libc.so.6

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

You don't need the lib-aout in /etc/ld.so.conf 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.

Author Comment

ID: 2573110
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 libc.so.6 was not linking to anything.  All I got was libc.so.4 => libc.so.4.7

I looked all over the net and had trouble finding any libc.so.6 downloads. So I went to gnu.org 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.


Accepted Solution

kiffney earned 225 total points
ID: 2573219
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 http://metalab.unc.edu/pub/Linux/distributions/redhat/current/i386/RedHat/RPMS/glibc-2.1.2-11.i386.rpm 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.

Author Comment

ID: 2573418
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?


Expert Comment

ID: 2573498
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 http://www.amazon.com/exec/obidos/ASIN/1565921518/craigbournecompaA/103-5144707-3790200.
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.

Expert Comment

ID: 2573539
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!

Author Comment

ID: 2574204
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?


Expert Comment

ID: 2574359
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.

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question