HP-UX /usr/lib/dld.sl: Can't open shared library:解决办法

我在HP-UX上编译完一个程序的时候,ldd 这个binary的时候发现程序link的lib并不是按照我在环境变量中设置的SHLIB_PATH,而是取了其他值.这个很奇怪,感觉link 的lib被hardcode。

ldd $ARBORBIN/MRM
        /usr/lib/libdld.2 =>    /usr/lib/libdld.2
        /usr/lib/libc.2 =>      /usr/lib/libc.2
        /usr/lib/libdld.2 =>    /usr/lib/libdld.2
        /usr/lib/libxti.2 =>    /usr/lib/libxti.2
        /usr/lib/libc.2 =>      /usr/lib/libc.2
        /usr/lib/libm.2 =>      /usr/lib/libm.2
        /usr/lib/libcl.2 =>     /usr/lib/libcl.2
        /usr/lib/libisamstub.1 =>       /usr/lib/libisamstub.1
        /usr/lib/libdld.2 =>    /usr/lib/libdld.2
        /usr1/arbor/3p/oracle/HPUX/lib/libclntsh.sl.9.0 =>      /usr1/arbor/3p/oracle/HPUX/lib/libclntsh.sl.9.0
        /usr/lib/libcl.2 =>     /usr/lib/libcl.2
        /usr/lib/libc.2 =>      /usr/lib/libc.2
        /usr/lib/libm.2 =>      /usr/lib/libm.2
        /usr/lib/libdld.2 =>    /usr/lib/libdld.2
        /usr/lib/libnss_dns.1 =>        /usr/lib/libnss_dns.1
        /usr/lib/libdld.2 =>    /usr/lib/libdld.2
        /usr/lib/libpthread.1 =>        /usr/lib/libpthread.1
        /usr/lib/librt.2 =>     /usr/lib/librt.2
        /db/ora_mnt1/app/oracle/product/9.2.0.5_Client/lib32/libwtc9.sl =>      /usr1/arbor/3poracle/HPUX/lib/libwtc9.sl
        /usr/lib/libpthread.1 =>        /usr/lib/libpthread.1
        /usr1/arbor/src/lib/liboam_emit.sl =>   /usr1/arbor/src/lib/liboam_emit.sl
        /usr/lib/libstd_v2.2 => /usr/lib/libstd_v2.2
        /usr/lib/libCsup_v2.2 =>        /usr/lib/libCsup_v2.2
        /usr1/arbor/src/lib/libismutil.sl =>    /usr1/arbor/src/lib/libismutil.sl

env |grep SH

15:SHLIB_PATH=/usr1/arbor/3pACE/ACE_wrappers/build/HPUX/ace:/usr1/arbor/3p/rosette/HPUX/rel/lib/

:/opt/app/oracle/product/9.2.0.5/lib32:/usr1/arbor/idesign_site/lib:/usr1/arbor/3pxml/xerces/HPUX/lib:/app/arborperl/5.8.2/lib.....



这样子的话,当程序放到客户的环境上是,客户那根本没有/usr1/arbor/3p/oracle/HPUX/lib这个目录,肯定就是找不到这个文件了.


于是在客户的环境上,出现了以下问题:
celcom@milhpit1@CELTCUS:/home/tss/celcom/celcom_tss/yyang 35 : ./MRM
/usr/lib/dld.sl: Can't open shared library: /usr1/arbor/3p/oracle/HPUX/lib/libclntsh.sl.9.0
/usr/lib/dld.sl: No such file or directory
Abort (core dumped)

celcom@milhpit1@CELTCUS:/home/tss/celcom/celcom_tss/yyang 54 : ldd  MRM
        /usr/lib/libdld.2 =>    /usr/lib/libdld.2
        /usr/lib/libc.2 =>      /usr/lib/libc.2
        /usr/lib/libdld.2 =>    /usr/lib/libdld.2
        /usr/lib/libxti.2 =>    /usr/lib/libxti.2
        /usr/lib/libc.2 =>      /usr/lib/libc.2
        /usr/lib/libm.2 =>      /usr/lib/libm.2
        /usr/lib/libcl.2 =>     /usr/lib/libcl.2
        /usr/lib/libisamstub.1 =>       /usr/lib/libisamstub.1
        /usr/lib/libdld.2 =>    /usr/lib/libdld.2
/usr/lib/dld.sl: Can't open shared library: /usr1/arbor/3p/oracle/HPUX/lib/libclntsh.sl.9.0
/usr/lib/dld.sl: No such file or directory

最后找到一个workaround方法,就是不用改程序,只是用chatr +s enable MRM
celcom@milhpit1@CELTCUS:/home/tss/celcom/celcom_tss/yyang 61 : chatr +s enable MRM
MRM:
   current values:
         normal executable
         shared library dynamic path search:
             SHLIB_PATH     disabled  second
             embedded path  disabled  first  Not Defined
         shared library list:
             dynamic   /usr1/arbor/src/lib/libismutil.sl
             dynamic   /usr/lib/libCsup_v2.2
             dynamic   /usr/lib/libstd_v2.2
             dynamic   /usr1/arbor/src/lib/liboam_emit.sl
             dynamic   /usr/lib/libpthread.1
             dynamic   /usr1/arbor/3p/oracle/HPUX/lib/libclntsh.sl.9.0
             dynamic   /usr/lib/libcl.2
             dynamic   /usr/lib/libm.2
             dynamic   /usr/lib/libc.2
             dynamic   /usr/lib/libxti.2
             static    /usr/lib/libdld.2
         shared library binding:
             deferred
         global hash table disabled
         plabel caching disabled
         global hash array size:1103
         global hash array nbuckets:3
         shared vtable support disabled
         explicit unloading enabled
         static branch prediction disabled
         executable from stack: D (default)
         kernel assisted branch prediction enabled
         lazy swap allocation disabled
         text segment locking disabled
         data segment locking disabled
         third quadrant private data space disabled
         fourth quadrant private data space disabled
         third quadrant global data space disabled
         data page size: D (default)
         instruction page size: D (default)
         nulptr references disabled
         shared library private mapping disabled
         shared library text merging disabled
   new values:
         normal executable
         shared library dynamic path search:
             SHLIB_PATH     enabled   second
             embedded path  disabled  first  Not Defined
         shared library list:
             dynamic   /usr1/arbor/src/lib/libismutil.sl
             dynamic   /usr/lib/libCsup_v2.2
             dynamic   /usr/lib/libstd_v2.2
             dynamic   /usr1/arbor/src/lib/liboam_emit.sl
             dynamic   /usr/lib/libpthread.1
             dynamic   /usr1/arbor/3p/oracle/HPUX/lib/libclntsh.sl.9.0
             dynamic   /usr/lib/libcl.2
             dynamic   /usr/lib/libm.2
             dynamic   /usr/lib/libc.2
             dynamic   /usr/lib/libxti.2
             static    /usr/lib/libdld.2
         shared library binding:
             deferred
         global hash table disabled
         plabel caching disabled
         global hash array size:1103
         global hash array nbuckets:3
         shared vtable support disabled
         explicit unloading enabled
         static branch prediction disabled
         executable from stack: D (default)
         kernel assisted branch prediction enabled
         lazy swap allocation disabled
         text segment locking disabled
         data segment locking disabled
         third quadrant private data space disabled
         fourth quadrant private data space disabled
         third quadrant global data space disabled
         data page size: D (default)
         instruction page size: D (default)
         nulptr references disabled
         shared library private mapping disabled
         shared library text merging disabled


我们ldd看一下:
celcom@milhpit1@CELTCUS:/home/tss/celcom/celcom_tss/yyang 62 : ldd MRM                /usr/lib/libdld.2 =>    /usr/lib/libdld.2
        /usr/lib/libc.2 =>      /lib/libc.2
        /usr/lib/libdld.2 =>    /lib/libdld.2
        /usr/lib/libxti.2 =>    /lib/libxti.2
        /usr/lib/libc.2 =>      /lib/libc.2
        /usr/lib/libm.2 =>      /lib/libm.2
        /usr/lib/libcl.2 =>     /lib/libcl.2
        /usr/lib/libisamstub.1 =>       /lib/libisamstub.1
        /usr/lib/libdld.2 =>    /lib/libdld.2
        /usr1/arbor/3p/oracle/HPUX/lib/libclntsh.sl.9.0 =>      /opt/app/oracle/product/9.2.0.5/lib32/libclntsh.sl.9.0
        /usr/lib/libcl.2 =>     /lib/libcl.2
        /usr/lib/libc.2 =>      /lib/libc.2
        /usr/lib/libm.2 =>      /lib/libm.2
        /usr/lib/libdld.2 =>    /lib/libdld.2
        /usr/lib/libnss_dns.1 =>        /lib/libnss_dns.1
        /usr/lib/libdld.2 =>    /lib/libdld.2
        /usr/lib/libpthread.1 =>        /lib/libpthread.1
        /usr/lib/librt.2 =>     /lib/librt.2
        /opt/app/oracle/product/9.2.0.5/lib32/libwtc9.sl =>     /opt/app/oracle/product/9.2.0.5/lib32/libwtc9.sl
        /usr/lib/libpthread.1 =>        /lib/libpthread.1
        /usr1/arbor/src/lib/liboam_emit.sl =>   /home/tss/celcom/celcom_tss/site_specific/lib/liboam_emit.sl
        /usr/lib/libstd_v2.2 => /lib/libstd_v2.2
        /usr/lib/libCsup_v2.2 =>        /lib/libCsup_v2.2

        /usr1/arbor/src/lib/libismutil.sl =>    /home/tss/celcom/celcom_tss/site_specific/lib/libismutil.sl


in summary :The chatr +s enable option allows a program to utilize SHLIB_PATH to locate shared libraries. 

你可能感兴趣的:(unix)