FFmpeg動態鏈接庫的運行時錯誤‘error while loading shared libraries: libx264.so’


1. 引言

該問題是在測試基於 FFmpeg 庫的播放器工程過程中產生的。
FFmpeg 是下載源碼后在本地編譯並安裝到指定路徑的,編譯時打開了 x264 的選項,x264 也是自行編譯安裝在本地的。

2. 問題描述

在編譯時沒有產生錯誤或者警告信息,正常生成了可執行文件,但在執行時產生了如下所示的動態鏈接錯誤。

error while loading shared libraries: libx264.so.161: cannot open shared object file: No such file or directory

3. 錯誤原因分析與解決

經過谷歌搜索很多類似的問題,最后發現錯誤產生的原因是 ffmpeg 版本與 x264 版本不兼容。
x264 是最新版代碼的 master 分支,生成的是 libx264.so.161 版本。

c347e7a0 (origin/master, origin/HEAD)

而我們使用的 FFmpeg 是 tag-3.3 的版本,經過測試最高兼容 libx264.so.154 的版本,因此需要對 x264進行降級。

# Info of FFmpeg source code
commit af8d5aab74c1fac2280e1a0b1e52c09b7e92e8b1 (HEAD -> release/3.3, origin/release/3.3)
Author: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Date:   Sat Apr 20 00:03:15 2019 +0200

一直降到 2017 年一月份的一個版本才使得可執行程序運行時不再報錯。

# Info of x264 source code
commit 2451a7282463f68e532f2eee090a70ab139bb3e7 (HEAD -> master)
Author: Vittorio Giovara <vittorio.giovara@gmail.com>
Date:   Fri Jan 6 17:50:40 2017 +0100

至此,從頭到尾可以正常運行了,在此記錄一下。

系統環境如下

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:        18.04
Codename:       bionic

$ gcc --version
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

$ pkg-config --version
0.29.1

$ cmake --version
cmake version 3.10.2

CMake suite maintained and supported by Kitware (kitware.co
m/cmake).

(全文完)


參考資料

[1] ffmpeg: error while loading shared libraries: libx264.so.138: cannot open shared object file: No such file or directory https://www.programmersought.com/article/77534038136/

[2] stremio: error while loading shared libraries: libx264.so.152: #243
https://github.com/Stremio/stremio-bugs/issues/243

本文作者 :phillee
發表日期 :2021年4月21日
本文鏈接https://www.cnblogs.com/phillee/p/14687067.html
版權聲明 :自由轉載-非商用-非衍生-保持署名(創意共享3.0許可協議/CC BY-NC-SA 3.0)。轉載請注明出處!
限於本人水平,如果文章和代碼有表述不當之處,還請不吝賜教。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM