--- In [email protected], "doorsofperception82" <msgcof...@...> wrote: > > Hi > > some one please explain the purpose of this file/directory. > > When do we need to use it and whether it is default on server os (in my case CentOS 5.2) >
Yes When you run a program your computer reads code from the binary file that is the program itself, e g /bin/ls is read and executed every time you execute the command "ls" However, in most cases not only the single binary executable file is enough but also some other files are needed. Those files also containing executable code are called dynamic libraries. You can see if a program depends on any dynamic libraries by using the ldd program, e g: $ ldd /bin/ls librt.so.1 => /lib/librt.so.1 (0x4002d000) libc.so.6 => /lib/libc.so.6 (0x40040000) libpthread.so.0 => /lib/libpthread.so.0 (0x40176000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) In this case ls depends on four different dynamic libraries. It is also possible to build static executable files that contain all the code needed in a single file but those executable files will then be a lot bigger. With the command $file you can see if a binary executable is a statically linked or dynamically linked. Some more examples: $ file /bin/ls /bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), stripped see "ls" is dynamically linked $ file /usr/local/bin/wine-preloader /usr/local/bin/wine-preloader: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, stripped wine-preloader is statically linked Now chk with the following $ ldd /usr/local/bin/wine-preloader not a dynamic executable Above Its not listing dynamic linked libraries Dynamic libaries are files that contain a version string in the file name, for eg libc.so.6 (so.6) and when executables like "ls" are linked not all sub versions are specified. Tofind the right library symbolic links are created from the right files with complete version numbers to files which can be found by executables. Refer /lib u will get many symblink files $ll /lib |grep ^l Those symbolic links are created by ldconfig. Each time when a new dynamic library is installed ldconfig should be run. Some more examples: $ file /lib/libpthread.so.0 /lib/libpthread.so.0: symbolic link to libpthread-0.10.so $ file /lib/libpthread-0.10.so /lib/libpthread-0.10.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), not stripped ldconfig Normally when a distribution installs a program through its package management system (for eg rpm -ivh) it automatically calls "ldconfig" to update the cache. If you manually compile and install a program it is therefore important to include the directory containing the programs libraries into "ld.so.conf" if the directories are not already listed and everytime "ldconfig" must be run to update the cache. This is the most common reason why people compile and install a program and then wonder why it doesn't run. When "ldconfig" is run it just goes through the directories listed in the "ld.so.conf" file and searches for any dynamically linked libraries there. When it finds them it adds their name and path to the "ld.so.cache" file in the /etc directory. Then when a program requires a library it calls the "ld.so" program and requests it. The "ld.so" program then looks in the ld.so.cache file for the name of the library and if it finds it, loads the library and makes it available for the requesting program. If "ld.so" doesn't find what it wants in the cache it can't supply the library . If u want libraries to load from different path u can mention in ld.so.conf For eg-: If u compiled imageMagik & .so are located in /usr/local/lib then do the following $touch /etc/ld.so.conf.d/imageMagick.conf Append /usr/local/lib under the created file or $echo "/usr/local/lib" > /etc/ld.so.conf.d/ImageMagick.conf Also verify /etc/ld.so.conf it shuld look like this include ld.so.conf.d/*.con Now run ldconfig (important) $ ldconfig ld-linux automatically causes the program loader to be loaded and run. On Linux systems, this loader is named /lib/ld-linux.so.X (where X is a version number). This loader, in turn, finds and loads all other shared libraries used by the program. Also refer The ld.so range of files and directories are connected with the dynamic linker so programs can easily find their dynamically linked libraries. These files and directories are basically just configuration files for the "ldconfigure" program to work on and a binary stored cache file for the "ld.so" runtime linker to read and load the required libraries. There can be several ld.so files and directories depending on your distribution. The most important is "ld.so.conf" . This is (duh!) the configuration file which tells the "ldconfig" program how to work. It is a very simple file and is just a list of directories where your libraries are situated. On some distributions (k/ubuntu) the file also references an "ld.so.conf.d" directory which sources dynamically installed files of directory lists which are sourced by "ld.so.conf". This is done to facilitate package management. Refrences http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html http://grahamwideman.wordpress.com/2009/02/09/the-linux-loader-and-how-i\ t-finds-libraries/ B.Sadhiq [Non-text portions of this message have been removed]
