Centos and RHEL: Maintaining Local Shared Object Libraries

Greg Peterson > Code

Rationale

Red Hat Enterprise Linux and CentOS system administrators may install and maintain software that is not included in vendor-supported repositories. Such software should be installed outside the base system, especially if the operating system is supported by a vendor. For example, /usr/local/share/ is suitable for an application server when client machines that run the same operating system mount /usr/local/share/ via NFS.

Linux computers use shared object libraries (*.so files) that are loaded as necessary by the dynamic linker, ld.so(8) or ld-linux.so(8). Configuration of this system is done by editing /etc/ld.so.conf and files in the /etc/ld.so.conf.d/ directory. The configuration can be installed and updated with the ldconfig(8) command.

Local shared libraries can be maintained by adding one line to /etc/ld.so.conf. This small modification works well in enterprise environments where vendors maintain the base Red Hat Enterprise Linux or CentOS system and enterprise system administrators maintain local software. Local software installation may be done without any further changes to the vendor-supported system.

Procedures

In order to add shared library files in /usr/local/share/ directories, I use this method (username and hostname have been changed for this document):

  1. Edit system configuration for ldconfig(8) in /etc/ld.so.conf (I did this when a new application server was installed in 2011)
      greg@gold% ls -l /etc/ld.so.conf
      -rw-r--r-- 1 root root 77 Oct  2  2011 /etc/ld.so.conf
      greg@gold% cat /etc/ld.so.conf
      include ld.so.conf.d/\*.conf
      include /usr/local/share/etc/ld.so.conf.d/*.conf
    
  2. Create a *.conf file for each directory in /usr/local/share/:
      greg@gold% ls -l /usr/local/share/etc/ld.so.conf.d/
      total 16
      -rw-r--r-- 1 root root  38 Oct  2  2011 ImageMagick.conf
      -rw-r--r-- 1 root root  29 Feb  5  2012 lib-centos6.conf
      -rw-r--r-- 1 root root  34 Oct  2  2011 R.conf
      -rw-r--r-- 1 root root 286 Oct  2  2011 README
      greg@gold% cat /usr/local/share/etc/ld.so.conf.d/lib-centos6.conf
      /usr/local/share/lib-centos6
    
  3. I compiled GNU Emacs on a CentOS-6.4 machine with the latest libraries A successful installation of the latest version of GNU Emacs required a newer version of libjpeg.so than we had on our application server. The JPEG library in /usr/lib/ is older, so I copied a newer library from another machine (latest version of CentOS-6-i686) to a local directory:
      greg@gold% ls -l /usr/local/share/lib-centos6/ | grep jpeg
      lrwxrwxrwx 1 root root      17 Mar 21 14:12 libjpeg.so -> libjpeg.so.62.0.0*
      lrwxrwxrwx 1 root root      17 Mar 21 14:12 libjpeg.so.62 -> libjpeg.so.62.0.0*
      -rwxr-xr-x 1 root root  291256 Feb 22 07:49 libjpeg.so.62.0.0*
    
  4. Each time we add a library (*.so file), “root” must update /etc/ld.so.cache:
      root@gold ~]# ldconfig
      [root@gold ~]# ldconfig -p | grep libjpeg
      libjpeg.so.62 (libc6) => /usr/local/share/lib-centos6/libjpeg.so.62
      libjpeg.so.62 (libc6) => /usr/lib/libjpeg.so.62
      libjpeg.so (libc6) => /usr/local/share/lib-centos6/libjpeg.so
      libjpeg.so (libc6) => /usr/lib/libjpeg.so
      [root@gold ~]#
    
  5. Client machines that mount /usr/local/share/ must update /etc/ld.so.cache as well. This can be done by running ldconfig(8) if necessary. At our university all client machines are dual-boot Windows 7 and CentOS computers. Students and instructors who use Linux start from cold boot or reboot from Windows 7.

(END 2013-03-23)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s