0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

lddで依存しているライブラリの一覧を得たい

Posted at

Dockerでコンテナを作ってる時に、あるプログラムが依存しているライブラリってどれだっけ?となって書いたもの。

ただlddを使うだけなのでリンク時に解決したライブラリしか見えません。
つまり実行時にdlopenで読むようなライブラリまではわかりません。例えばglibcのnssのようにファイルに書いてある内容によって読むライブラリを決定するようなものとかです。

RHEL 7 で確認。芋づる式に実行して最後にsort | uniqで重複を消すだけ。

deps.sh
# !/bin/bash

# usage) bash deps.sh /usr/bin/executable-file

function deps(){
  local file=$1
  ldd "$file" | awk '{print $3}' | while read line; do
    if [ "$line" = "" ]; then
      continue
    fi
    echo "$line"
    deps "$line"
  done
}

deps "$1" | sort | uniq
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?