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)。转载请注明出处!
限于本人水平,如果文章和代码有表述不当之处,还请不吝赐教。

posted @ 2021-04-21 21:45  coffee_tea_or_me  阅读(2923)  评论(0编辑  收藏  举报