The purpose of this note is to document the use of LD_LIBRARY_PATH and
SHLIB_PATH on HP-UX.
SCOPE & APPLICATION
-------------------
This note is intended for DBAs and Support Personnel.
USE OF LD_LIBRARY_PATH and SHLIB_PATH on HP-UX
==============================================
1. INTRODUCTION
------------
On HP-UX 10.20 and 11 (32 bit), LD_LIBRARY_PATH is not checked by the dynamic
loader when locating shared libraries required to start an executable.
These versions of HP-UX will check the environment variable SHLIB_PATH instead.
On HP-UX 11 (64 bit), however, both LD_LIBRARY_PATH and SHLIB_PATH are valid.
In addition, on all three versions of HP-UX, an 'embedded path' can be
given at link time. This is a list of path names that will be searched.
Further, the use of these environment variables can be enabled/disabled
dynamically (ie, do not require a relink).
2. WILL LD_LIBRARY_PATH/SHLIB_PATH BE USED?
----------------------------------------
The 'chatr' command will verify if these environment variables are used.
Consider the following examples (note, the line numbers have been added here
to aid explanation).
Note, 'chatr' is similar to the 'ldd' command found on SVR4 UNIX.
2a. HP-UX 10.20, HP-UX 11 (32 bit)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% cd $ORACLE_HOME/bin
% chatr oracle
1 oracle:
2 shared executable
3 shared library dynamic path search:
4 SHLIB_PATH enabled second
5 embedded path disabled first Not Defined
6 shared library list:
7 dynamic /oracle/OFA_base/app/oracle/product/8.0.6.0/lib/libobk.sl
8 dynamic /usr/lib/librt.2
9 dynamic /usr/lib/libpthread.1
10 dynamic /usr/lib/libnss_dns.1
11 dynamic /usr/lib/libdld.2
12 dynamic /usr/lib/libm.2
13 dynamic /usr/lib/libc.2
<... lots more output here ...>
line 1 shows the name of the executable
line 2 is similar to the output of 'file <exe name>'
lines 3-5 show
a. usage of the environment variable SHLIB_PATH is enabled
b. an embedded search path was not given at link time
line 6 onwards gives a list of shared libraries that will be loaded at runtime
Note that full path names are given.
2b. HP-UX 11 (64 bit)
~~~~~~~~~~~~~~~~~
% cd $ORACLE_HOME/bin
% chatr oracle
1 oracle:
2 64-bit ELF executable
3 shared library dynamic path search:
4 LD_LIBRARY_PATH enabled first
5 SHLIB_PATH enabled second
6 embedded path enabled third /oracle/OFA_base/app/oracle/
product/8.1.6_64/lib64:/oracle/OFA_base/app/oracle/product/
8.1.6_64/rdbms/lib64:/usr/lib/pa20_64:
/opt/langtools/lib/pa20_64:
7 shared library list:
8 libwtc8.sl
9 libjox8.sl
10 libobk.sl
11 librt.2
12 libpthread.1
13 libnss_dns.1
14 libdl.1
15 libm.2
16 libc.2
<... lots more output here ...>
In this case, line 2 shows that this is a 64 bit executable
lines 4,5,6 show that each aspect of the dynamic path search is enabled, and
also gives the search order line 7 onwards shows the dynamic libraries linked into the executable.
Note that the full path names have not been given in this case.
3. ENABLING/DISABLING USE OF LD_LIBRARY_PATH/SHLIB_PATH
----------------------------------------------------
chatr is used to enable or disable SHLIB_PATH and LD_LIBRARY_PATH :
% chatr +s enable <executable>
or
% chatr +s disable <executable>
On HP-UX 10.20 and 11 (32 bit), this enables/disables SHLIB_PATH only.
On HP-UX 11 (64 bit), both SHLIB_PATH and LD_LIBRARY_PATH are enabled/disabled.
The embedded path is defined during relink by specifying the +s and +b linker
flags.
4. HOW A SHARED LIBRARY IS LOCATED
-------------------------------
From the output given in (2a), since full path names are given for libraries,
these will be searched first. If a library is not present in that location,
then SHLIB_PATH will be searched, as it is enabled. The embedded path will
not be searched as it is disabled.
If a shared library cannot be found, an error of the form
/usr/lib/dld.sl: Can't find path for shared library: libobk.sl
/usr/lib/dld.sl: No such file or directory
will be seen.
From the output given in (2b), since full path names to libraries are not
given, and all search paths are enabled, the following search order will be
used:
i. $LD_LIBRARY_PATH
ii. $SHLIB_PATH
iii. the given embedded search paths
If a shared library cannot be found, an error of the form
/usr/lib/pa20_64/dld.sl: Unable to find library 'libwtc8.sl'.
will be seen.
5. WHICH VARIABLE SHOULD BE SET FOR 64 BIT ORACLE?
-----------------------------------------------
A 64 bit install of Oracle includes both 32 bit executables (such as svrmgrl
and sqlplus) and 64 bit executables (such as oracle).
The installation contains two 'lib' areas:
Prior to 9i:
$ORACLE_HOME/lib - 32 bit libs
$ORACLE_HOME/lib64 - 64 bit libs
9i onwards:
$ORACLE_HOME/lib32 - 32 bit libs
$ORACLE_HOME/lib - 64 bit libs
Both of these directories contain libraries of the same name. To ensure
that 32 bit executables search the 32 bit dir, and 64 bit executables
search the 64 bit dir, set the following:
Prior to 9i:
$LD_LIBRARY_PATH - includes $ORACLE_HOME/lib64, but not $ORACLE_HOME/lib
$SHLIB_PATH - includes $ORACLE_HOME/lib, but not $ORACLE_HOME/lib64
9i onwards:
$LD_LIBRARY_PATH - includes $ORACLE_HOME/lib, but not $ORACLE_HOME/lib32
$SHLIB_PATH - includes $ORACLE_HOME/lib32, but not $ORACLE_HOME/lib
© 2004, www.oracledatabase12g.com. 版权所有.文章允许转载,但必须以链接方式注明源地址,否则追究法律责任.
相关文章 | Related posts:




最新评论