Like which, for dynamic libraries
  • C 69.7%
  • Shell 24.6%
  • Makefile 5.7%
Find a file
Jameson Nash 6fc9000e48
Make new AppVeyor security token
Hopefully will work next time I make a release to automate direct
artifact uploading.
2026-02-13 14:28:37 -05:00
.github/workflows switch travis-ci to github-actions (#19) 2022-10-31 16:05:14 -04:00
.appveyor.yml Make new AppVeyor security token 2026-02-13 14:28:37 -05:00
.gitignore Add Windows support 2017-12-12 15:13:00 -05:00
libwhich.c allow additional search paths (#25) 2026-02-13 14:11:04 -05:00
LICENSE Initial commit 2017-07-18 13:41:54 -04:00
Makefile add make install step (#18) 2022-10-31 16:11:31 -04:00
README.md add options for scriptable usage 2017-11-25 17:40:01 -05:00
test-libwhich.sh switch travis-ci to github-actions (#19) 2022-10-31 16:05:14 -04:00

libwhich

Like which, for dynamic libraries.

Also a bit like ldd and otool -L.

Sample usage:

$ ./libwhich libgobject-2.0.so
library:
  /usr/lib/x86_64-linux-gnu/libgobject-2.0.so

dependencies:
  /lib/x86_64-linux-gnu/libdl.so.2
  /lib/x86_64-linux-gnu/libc.so.6
  /lib64/ld-linux-x86-64.so.2
+ /usr/lib/x86_64-linux-gnu/libgobject-2.0.so
+ /lib/x86_64-linux-gnu/libglib-2.0.so.0
+ /usr/lib/x86_64-linux-gnu/libffi.so.6
+ /lib/x86_64-linux-gnu/libpcre.so.3
+ /lib/x86_64-linux-gnu/libpthread.so.0

On Darwin, this resolves the library paths fully. To reverse that, feed the library path to otool -D.

On Linux, this returns the computed path from which the shared library was loaded. To normalize the path instead, use readlink.

For script usage, the following options are also supported:

$ ./libwhich -p <library>
  • -p print just the library path to stdout
  • -a print all dependencies (including the library itself) to stdout, separated by NUL (``\0'') characters
  • -d direct dependencies (excluding the library), separated by NUL (``\0'') characters

Building

Building is straightforward: just run make.

Run tests with ./test-libwhich.sh or make check (requires gsed).