Dynamic-Linking
即使在庫路徑中也找不到共享對象文件
我正在嘗試從原始碼安裝 plexmediaplayer。這涉及編譯我已經完成並安裝在 /usr/local/lib 下的 libmpv.so.1
當我執行 plexmediaplayer 時,我收到以下錯誤:
$ plexmediaplayer plexmediaplayer: error while loading shared libraries: libmpv.so.1: cannot open shared object file: No such file or directory
ldconfig 正確找到庫:
$ ldconfig -v | grep libmpv libmpv.so.1 -> libmpv.so.1.24.0
plexmiediaplayer 二進製文件上的 ldd 顯示 libmpv:
$ ldd plexmediaplayer | grep libmpv libmpv.so.1 => /usr/local/lib/libmpv.so.1 (0x00007f2fe4f33000)
這是一個符號連結:
ls -l /usr/local/lib/libmpv.so.1 lrwxrwxrwx 1 root root 16 Feb 9 20:37 /usr/local/lib/libmpv.so.1 -> libmpv.so.1.24.0
共享對象和執行檔都是針對 x86_64 編譯的,並且可以由非 root 使用者嘗試執行 plexmediaplayer 讀取:
$ file /usr/local/lib/libmpv.so.1.24.0 /usr/local/lib/libmpv.so.1.24.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=855d9cbf952c76e3c0c1c1a162c4c94ea5a12b91, not stripped $ file /usr/local/bin/plexmediaplayer /usr/local/bin/plexmediaplayer: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=dc92ac026c5ac7bc3e5554a591321de81a3f4576, not stripped
這些都與我的機器拱門相匹配:
$ uname -a Linux hostname 4.4.0-66-generic #87-Ubuntu SMP Fri Mar 3 15:29:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
在 plexmediaplayer 上執行 strace 會得到以下結果:
$ strace -o lotsalogs -ff -e trace=file plexmediaplayer open("/opt/Qt5.8.0/5.8/gcc_64//lib/tls/x86_64/libmpv.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/opt/Qt5.8.0/5.8/gcc_64//lib/tls/libmpv.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/opt/Qt5.8.0/5.8/gcc_64//lib/x86_64/libmpv.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/opt/Qt5.8.0/5.8/gcc_64//lib/libmpv.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/usr/local/lib/libmpv.so.1", O_RDONLY|O_CLOEXEC) = -1 EACCES (Permission denied) open("/lib/x86_64-linux-gnu/tls/x86_64/libmpv.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/lib/x86_64-linux-gnu/tls/libmpv.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/lib/x86_64-linux-gnu/x86_64/libmpv.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/lib/x86_64-linux-gnu/libmpv.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/usr/lib/x86_64-linux-gnu/tls/x86_64/libmpv.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/usr/lib/x86_64-linux-gnu/tls/libmpv.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/usr/lib/x86_64-linux-gnu/x86_64/libmpv.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/usr/lib/x86_64-linux-gnu/libmpv.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/lib/tls/x86_64/libmpv.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/lib/tls/libmpv.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/lib/x86_64/libmpv.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/lib/libmpv.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/usr/lib/tls/x86_64/libmpv.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/usr/lib/tls/libmpv.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/usr/lib/x86_64/libmpv.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/usr/lib/libmpv.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
包括:
open("/usr/local/lib/libmpv.so.1", O_RDONLY|O_CLOEXEC) = -1 EACCES (Permission denied)
但通過符號連結對文件的權限是:
ls -l /usr/local/lib/libmpv.so.1.24.0 -rwxr-xr-x 1 root root 27872856 Mar 22 22:17 /usr/local/lib/libmpv.so.1.24.0
任何想法為什麼我的二進製文件找不到這個?
編輯:我擦除了下的所有 libmpv 和下的
/usr/local/lib
plexmediaplayer/usr/local/bin
,並被源目錄刪除,然後在 VM 中並排重新安裝。虛擬機中的建構工作,我的主機上的那個沒有。我還在兩台機器上對 ld 進行了雜湊處理,並且(不出所料)它們匹配。
事實證明,我(糟糕?)幾個月前為 plexmediaplayer 配置了 apparmor,這導致更新和重新編譯時出現問題。
我能夠通過執行來解決這個問題
sudo cp /usr/local/lib/libmpv*.so /usr/lib32
ldd plexmediaplayer
顯示相同,儘管庫在那裡,但它們沒有工作。