Solaris Application Programming, 1/e - Chapter 4 - Parent Directory
Solaris Application Programming, 1/e - Chapter 4 - Parent Directory
Solaris Application Programming, 1/e - Chapter 4 - Parent Directory
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
4.5 INFORMATION ABOUT APPLICATIONS 85<br />
Example 4.51 The -r Option for ldd<br />
$ ldd -r someapp<br />
libdl.so.1 => /usr/lib/libdl.so.1<br />
libnsl.so.1 => /usr/lib/libnsl.so.1<br />
libgen.so.1 => /usr/lib/libgen.so.1<br />
libm.so.1 => /usr/lib/libm.so.1<br />
libc.so.1 => /usr/lib/libc.so.1<br />
libsocket.so.1 => /usr/lib/libsocket.so.1<br />
libsunmath.so.1 => (file not found)<br />
libelf.so.1 => /usr/lib/libelf.so.1<br />
libmp.so.2 => /usr/lib/libmp.so.2<br />
/usr/platform/SUNW,Sun-Blade-1000/lib/libc_psr.so.1<br />
symbol not found: sqrtf<br />
(someapp)<br />
symbol not found: sqrtl<br />
(someapp)<br />
The paths where libraries are located are hard-coded into the application at link<br />
time. I will cover the procedure for doing this in more detail in Section 7.2.6 of<br />
<strong>Chapter</strong> 7. At runtime, it is possible to use the LD_LIBRARY_PATH environment<br />
variable to override where the application finds libraries, or to assist the application<br />
in locating a particular library. So, for the case in Example 4.51, if the LD_<br />
LIBRARY_PATH variable were set to point to a directory containing libsunmath.so,<br />
ldd would report that the application used that version of the library.<br />
Example 4.52 shows an example of setting the LD_LIBRARY_PATH environment<br />
variable under csh. Of course, you can use the same environment variable to<br />
change where the application loads all its libraries from, so be careful when setting<br />
it and do not rely on it as the default mechanism to enable an application<br />
locating its libraries at deployment.<br />
Example 4.52 Example of Setting the LD_LIBRARY_PATH Variable<br />
$ setenv LD_LIBRARY_PATH /export/home/my_libraries/<br />
The LD_LIBRARY_PATH environment variable will override the search path for<br />
both 32-bit and 64-bit applications. To explicitly set search paths for these two<br />
application types you can use the environment variables LD_LIBRARY_PATH_32<br />
and LD_LIBRARY_PATH_64.<br />
It is also possible to set the LD_PRELOAD environment variable to specify a<br />
library that is to be loaded before the application. This enables the use of a different<br />
library in addition to the one shipped with the application. This can be a useful<br />
way to debug the application’s interactions with libraries. I will cover this in<br />
more detail in Section 7.2.10 of <strong>Chapter</strong> 7.