linux上使用LD_DEBUG環境變數檢視程式使用哪些庫

ztsinghua發表於2015-08-03
使用ldd命令可以知道程式依賴於哪些庫,在找不到這些庫的時候,使用LD_DEBUG可以知道系統在哪些路徑下進行了嘗試。
  例如:
[gliang1@localhost Linux2.6_64]$ ldd PS_AppServer_64bit
        libtux.so => not found
        libbuft.so => not found
        libfml.so => not found
        libfml32.so => not found
        libengine.so => not found
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00000033ff200000)
        libutrace.so => not found
        libusort.so => not found
        libicuuc.so.32 => not found
        libicuio.so.32 => not found
        libicui18n.so.32 => not found
        libicudata.so.32 => not found
        libxerces-c.so.28 => not found
        libfglproc.so => not found
        libdl.so.2 => /lib64/libdl.so.2 (0x00000033fee00000)
        libgiconv.so => not found
        libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x0000003411000000)
        libm.so.6 => /lib64/libm.so.6 (0x00000033ff600000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x000000340e800000)
        libc.so.6 => /lib64/libc.so.6 (0x00000033fea00000)
        /lib64/ld-linux-x86-64.so.2 (0x00000033fe600000)

使用LD_DEBUG檢視:
[gliang1@localhost Linux2.6_64]$ LD_DEBUG=libs ./PS_AppServer_64bit                     
     15285:     find library=libtux.so [0]; searching
     15285:      search cache=/etc/ld.so.cache
     15285:      search path=/lib64/tls/x86_64:/lib64/tls:/lib64/x86_64:/lib64:/usr/lib64/tls/x86_64:/usr/lib64/tls:/usr/lib64/x86_64:/usr/lib64            (system search path)
     15285:       trying file=/lib64/tls/x86_64/libtux.so
     15285:       trying file=/lib64/tls/libtux.so
     15285:       trying file=/lib64/x86_64/libtux.so
     15285:       trying file=/lib64/libtux.so
     15285:     

相關文章