Adding Library in Linux
Willy Sudiarto Raharjo
12 May 2006
0 comment

Introduction

GNU/Linux comes with so many libraries included out-of-the-box. It's part of Open Source programming model to use shared libraries as much as possible. It reduces so many problem that arose when each application comes with their own libraries. You will have so much library redundancy when you should only need one library to do all of that. In this article i want to give a solution when you need to add new library onto your system and let it detect the new library as sometimes you will need new libraries to install new software or upgrade to newer version.

Caching

When you install new library, usually people use --prefix parameter to decide which location should be used to put the new library, but some other people will just compile with default configuration by executing ./configure script. If you use the --prefix, make sure you remember the location as you will need to add them to the special file called ld.so.conf which is located in /etc directory. If you don't use any special parameter, usually it will install in default directory for libraries in GNU/Linux, so it shouldn't be a problem as it will be detected automatically. This file should consist of directories where all the libraries reside. The system will look on directory specified in the /etc/ld.so.conf when it needs to locate spesific library. Usually, system uses caching method to remember the locations of the libraries.

At some distro (i use Slackware), system will update their cache of the directory listing everytime it boots, because it is executed at boot script. It will make sure that your system will know if there is a new library installed before and you forgot to update the cache. Should you need to update manually, you can execute /sbin/ldconfig command to update your cache. It may take some time to finish this operation, mostly if you have installed many libraries on your system. Your system's cache will be located at /etc/ld.so.cache.

So, should you fail to install a program which ask for some library that have been installed, you can have two solutions on it. The first is by adding the directory where the library resides to /etc/ld.so.conf file and run ldconfig to update the cache, or if you only need a temporary solution, you can use LD_LIBRARY_PATH to point to the library directory by exporting the variable with this code:

export LD_LIBRARY_PATH=/path/to/library

Please remember that by using export, it is just temporary. When you close your terminal and open it again, the variable will be lost and you may have to add it again. You can put the export line in your .bash_profile file located on your home directory or if you want to be global, put it in /etc/profile file.

Last Update : 5 June 2006 :: 15:10:29

Comments

No comments yet

Post Your Comments

Your Name: *Comment:
Kode Rahasia

*Write code above:
Note: * denotes required field