Dependency resolution in Linux

后端 未结 4 1202
情深已故
情深已故 2021-01-05 03:26

Under Windows I have used a program called dependency walker to examine the libraries the application is using. I was wondering how I can achieve this on Linux for a standar

相关标签:
4条回答
  • 2021-01-05 04:14

    Use ldd

    ldd /bin/sh
    
    0 讨论(0)
  • 2021-01-05 04:16

    Try:

    ldd executable
    

    For example:

    [me@somebox ~]$ ldd /bin/ls
            linux-gate.so.1 =>  (0xb7f57000)
            librt.so.1 => /lib/tls/i686/cmov/librt.so.1 (0xb7f4c000)
            libselinux.so.1 => /lib/libselinux.so.1 (0xb7f32000)
            libacl.so.1 => /lib/libacl.so.1 (0xb7f2b000)
            libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7ddc000)
            libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb7dc4000)
            /lib/ld-linux.so.2 (0xb7f58000)
            libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb7dc0000)
            libattr.so.1 => /lib/libattr.so.1 (0xb7dbb000)
    [me@somebox ~]$ 
    

    Note that this will only report shared libraries. If you need to find out what static libraries were linked in at compile time, that's a bit trickier, especially seeing as your executable is 'stripped' (no debugging symbols).

    0 讨论(0)
  • 2021-01-05 04:18

    Use ldd. It will show the dynamic libraries the binary needs.

    Note that the libraries themselves may in turn need more libraries. To get these, you can run ldd on the libraries you got from running ldd on the binary.

    0 讨论(0)
  • 2021-01-05 04:23

    If you want something a little less raw than iteratively calling ldd and somewhat more like MSVC depends, you should try Visual-ldd. It hasn't been updated in 4 years, but it should still work given that the ELF format hasn't changed. It still won't show you individual symbols inside those libraries - for that you'll need something like nm, and I don't know of any GUI wrapper for that, unfortunately.

    0 讨论(0)
提交回复
热议问题