Tag Archives: solaris

Solaris Shared Library Troubleshooting Notes

Recently I have been building a few packages under an OpenSolaris Zone hosted by Joyent. Ran into a few issues with shared libraries, so here are my notes:

Telling the Linker Where to Look

You will often get an error like ld.so.1: conftest: fatal: libreadline.so.5: open failed: No such file or directory. This simply means the linker can not find your library. The following command will tell the linker to append a new entry to the existing search path:  

# crle -u /path/to/lib/dir
You can retrieve the current configuration by simply running crle on it’s own, output should be something like this:
$ crle
Configuration file [version 4]: /var/ld/ld.config
  Platform:     32-bit LSB 80386
  Default Library Path (ELF):   /opt/local/lib:/opt/csw/lib:/usr/lib:/lib
  Trusted Directories (ELF):    /lib/secure:/usr/lib/secure  (system default)
Command line:
  crle -c /var/ld/ld.config -l /opt/local/lib:/opt/csw/lib:/usr/lib:/lib
 

Getting Yourself Out of Trouble

You can easily get yourself into a situation where your system is a brick by having an incomplete search path for the linker. For example, if you run crle -l /foo/path/lib, you will no longer be able to run anything at all since the linker will not find basic libraries it needs. I found a great post on this topic which instructs you do use the LD_NOCONFIG environment variable to tell the linker to use a default configuration. You can then fix the issue:

$ sudo crle -l /opt/local/lib -l /opt/csw/lib -l /usr/lib -l /lib
ld.so.1: sudo: fatal: libpam.so.1: open failed: No such file or directory
Killed
$ LD_NOCONFIG=yes sudo crle -l /opt/local/lib -l /opt/csw/lib -l /usr/lib -l /lib