ubuntu 的 ffmpeg 静态库和我编译的 ffmpeg 静态库有什么区别?

ubuntu 的 ffmpeg 静态库和我编译的 ffmpeg 静态库有什么区别?

我尝试了来自 ubuntu 存储库的 ffmpeg,链接它们非常简单-lavcodec -lavuitl ...。然后我使用以下配置编译了我的代码:

    ./configure \
    --prefix=${BUILD_DIR}/desktop/x86_64 \
    --extra-cflags="-I$HOME/ffmpeg_build/include" \
    --extra-ldflags="-L$HOME/ffmpeg_build/lib" \
    --enable-shared \
    --arch=x86_64 \
    --enable-vaapi \
    --disable-vaapi \
    --enable-opencl \
    --disable-debug \
    --enable-nvenc \
    --enable-cuda \
    --enable-cuvid \
    --enable-libvpx \
    --enable-libdrm \
    --enable-gpl \
    --enable-runtime-cpudetect \
    --enable-libfdk-aac \
    --enable-libx264 \
    --enable-openssl \
    --enable-pic \
    --extra-libs="-lpthread -lm -lz -ldl" \
    --enable-nonfree 

它生成的静态库与 ubuntu 存储库提供的一样。但是,我无法简单地链接它们,-lavcodec -lavuitl ...因为我得到了很多未定义的引用,例如

../../../deps/ffmpeg/build/desktop/x86_64/lib/libavcodec.a(libfdk-aacdec.o): In function `fdk_aac_decode_frame':
libfdk-aacdec.c:(.text+0x4f): undefined reference to `aacDecoder_Fill'
libfdk-aacdec.c:(.text+0x6d): undefined reference to `aacDecoder_DecodeFrame'
libfdk-aacdec.c:(.text+0x8d): undefined reference to `aacDecoder_GetStreamInfo'
../../../deps/ffmpeg/build/desktop/x86_64/lib/libavcodec.a(libfdk-aacdec.o): In function `fdk_aac_decode_close':
libfdk-aacdec.c:(.text.unlikely+0xf): undefined reference to `aacDecoder_Close'
../../../deps/ffmpeg/build/desktop/x86_64/lib/libavcodec.a(libfdk-aacdec.o): In function `fdk_aac_decode_init':
libfdk-aacdec.c:(.text.unlikely+0x45): undefined reference to `aacDecoder_Open'
libfdk-aacdec.c:(.text.unlikely+0x82): undefined reference to `aacDecoder_ConfigRaw'
libfdk-aacdec.c:(.text.unlikely+0xb7): undefined reference to `aacDecoder_SetParam'
libfdk-aacdec.c:(.text.unlikely+0x129): undefined reference to `aacDecoder_SetParam'
libfdk-aacdec.c:(.text.unlikely+0x187): undefined reference to `aacDecoder_AncDataInit'
libfdk-aacdec.c:(.text.unlikely+0x1ac): undefined reference to `aacDecoder_SetParam'
libfdk-aacdec.c:(.text.unlikely+0x1d1): undefined reference to `aacDecoder_SetParam'
libfdk-aacdec.c:(.text.unlikely+0x1f2): undefined reference to `aacDecoder_SetParam'
libfdk-aacdec.c:(.text.unlikely+0x213): undefined reference to `aacDecoder_SetParam'
libfdk-aacdec.c:(.text.unlikely+0x22f): undefined reference to `aacDecoder_SetParam'
../../../deps/ffmpeg/build/desktop/x86_64/lib/libavcodec.a(libfdk-aacdec.o):libfdk-aacdec.c:(.text.unlikely+0x250): more undefined references to `aacDecoder_SetParam' follow
../../../deps/ffmpeg/build/desktop/x86_64/lib/libavcodec.a(libfdk-aacenc.o): In function `aac_encode_close':
libfdk-aacenc.c:(.text+0xf9): undefined reference to `aacEncClose'
../../../deps/ffmpeg/build/desktop/x86_64/lib/libavcodec.a(libfdk-aacenc.o): In function `aac_encode_frame':
libfdk-aacenc.c:(.text+0x2c1): undefined reference to `aacEncEncode'
../../../deps/ffmpeg/build/desktop/x86_64/lib/libavcodec.a(libfdk-aacenc.o): In function `aac_encode_init':
libfdk-aacenc.c:(.text.unlikely+0x3c): undefined reference to `aacEncOpen'
libfdk-aacenc.c:(.text.unlikely+0x7c): undefined reference to `aacEncoder_SetParam'
libfdk-aacenc.c:(.text.unlikely+0xb8): undefined reference to `aacEncoder_SetParam'
libfdk-aacenc.c:(.text.unlikely+0xfa): undefined reference to `aacEncoder_SetParam'
libfdk-aacenc.c:(.text.unlikely+0x180): undefined reference to `aacEncoder_SetParam'
libfdk-aacenc.c:(.text.unlikely+0x25d): undefined reference to `aacEncoder_SetParam'
../../../deps/ffmpeg/build/desktop/x86_64/lib/libavcodec.a(libfdk-aacenc.o):libfdk-aacenc.c:(.text.unlikely+0x28d): more undefined references to `aacEncoder_SetParam' follow
../../../deps/ffmpeg/build/desktop/x86_64/lib/libavcodec.a(libfdk-aacenc.o): In function `aac_encode_init':
libfdk-aacenc.c:(.text.unlikely+0x567): undefined reference to `aacEncEncode'
libfdk-aacenc.c:(.text.unlikely+0x5a1): undefined reference to `aacEncInfo'
../../../deps/ffmpeg/build/desktop/x86_64/lib/libavcodec.a(libvpxdec.o): In function `vpx_decode':
libvpxdec.c:(.text+0x58): undefined reference to `vpx_codec_decode'
libvpxdec.c:(.text+0xa2): undefined reference to `vpx_codec_get_frame'
libvpxdec.c:(.text+0x10c): undefined reference to `vpx_codec_error'
libvpxdec.c:(.text+0x117): undefined reference to `vpx_codec_error_detail'
libvpxdec.c:(.text+0x19e): undefined reference to `vpx_codec_decode'
libvpxdec.c:(.text+0x1ae): undefined reference to `vpx_codec_error'
libvpxdec.c:(.text+0x1ca): undefined reference to `vpx_codec_get_frame'
libvpxdec.c:(.text+0x560): undefined reference to `vpx_codec_vp9_dx_algo'
libvpxdec.c:(.text+0x58f): undefined reference to `vpx_codec_vp8_dx_algo'
../../../deps/ffmpeg/build/desktop/x86_64/lib/libavcodec.a(libvpxdec.o): In function `vpx_free':
libvpxdec.c:(.text.unlikely+0x9): undefined reference to `vpx_codec_destroy'
libvpxdec.c:(.text.unlikely+0x18): undefined reference to `vpx_codec_destroy'
../../../deps/ffmpeg/build/desktop/x86_64/lib/libavcodec.a(libvpxdec.o): In function `vpx_init':
libvpxdec.c:(.text.unlikely+0x87): undefined reference to `vpx_codec_version_str'
libvpxdec.c:(.text.unlikely+0xa5): undefined reference to `vpx_codec_build_config'
libvpxdec.c:(.text.unlikely+0xdf): undefined reference to `vpx_codec_dec_init_ver'
libvpxdec.c:(.text.unlikely+0xed): undefined reference to `vpx_codec_error'
../../../deps/ffmpeg/build/desktop/x86_64/lib/libavcodec.a(libvpxdec.o): In function `vp8_init':
libvpxdec.c:(.text.unlikely+0x134): undefined reference to `vpx_codec_vp8_dx_algo'
../../../deps/ffmpeg/build/desktop/x86_64/lib/libavcodec.a(libvpxdec.o): In function `vp9_init':
libvpxdec.c:(.text.unlikely+0x142): undefined reference to `vpx_codec_vp9_dx_algo'
../../../deps/ffmpeg/build/desktop/x86_64/lib/libavcodec.a(libvpxenc.o): In function `vpx_encode':
libvpxenc.c:(.text+0xda): undefined reference to `vpx_codec_encode'
libvpxenc.c:(.text+0x2b3): undefined reference to `vpx_codec_encode'
libvpxenc.c:(.text+0x33a): undefined reference to `vpx_codec_get_cx_data'
libvpxenc.c:(.text+0x3cd): undefined reference to `vpx_codec_get_cx_data'
../../../deps/ffmpeg/build/desktop/x86_64/lib/libavcodec.a(libvpxenc.o): In function `log_encoder_error':
libvpxenc.c:(.text.unlikely+0x351): undefined reference to `vpx_codec_error'
libvpxenc.c:(.text.unlikely+0x35c): undefined reference to `vpx_codec_error_detail'
../../../deps/ffmpeg/build/desktop/x86_64/lib/libavcodec.a(libvpxenc.o): In function `codecctl_int':
libvpxenc.c:(.text.unlikely+0x43a): undefined reference to `vpx_codec_control_'
../../../deps/ffmpeg/build/desktop/x86_64/lib/libavcodec.a(libvpxenc.o): In function `vpx_init':
libvpxenc.c:(.text.unlikely+0x4fb): undefined reference to `vpx_codec_get_caps'
libvpxenc.c:(.text.unlikely+0x503): undefined reference to `vpx_codec_version_str'
libvpxenc.c:(.text.unlikely+0x521): undefined reference to `vpx_codec_build_config'
libvpxenc.c:(.text.unlikely+0x563): undefined reference to `vpx_codec_enc_config_default'
libvpxenc.c:(.text.unlikely+0x573): undefined reference to `vpx_codec_err_to_string'
libvpxenc.c:(.text.unlikely+0xc2c): undefined reference to `vpx_codec_enc_init_ver'
libvpxenc.c:(.text.unlikely+0xc86): undefined reference to `vpx_codec_enc_init_ver'
libvpxenc.c:(.text.unlikely+0xffb): undefined reference to `vpx_img_wrap'
libvpxenc.c:(.text.unlikely+0x1040): undefined reference to `vpx_img_wrap'
../../../deps/ffmpeg/build/desktop/x86_64/lib/libavcodec.a(libvpxenc.o): In function `vp8_init':
libvpxenc.c:(.text.unlikely+0x10be): undefined reference to `vpx_codec_vp8_cx'
../../../deps/ffmpeg/build/desktop/x86_64/lib/libavcodec.a(libvpxenc.o): In function `vp9_init':
libvpxenc.c:(.text.unlikely+0x10d3): undefined reference to `vpx_codec_vp9_cx'
../../../deps/ffmpeg/build/desktop/x86_64/lib/libavcodec.a(libvpxenc.o): In function `vpx_free':
...

为什么 ubuntu 可以不依赖,x264, libfdk-aacdec, libvpxdec, etc但是当我使用我编译的库时却必须提供它们?

答案1

最新的适用于 Ubuntu 的 ffmpeg (7:4.1.3-0ubuntu1)(迪斯科丁戈)(截至 2022 年,ffmpeg(7:4.4-6ubuntu5)顽皮)可从该网页底部获取。Ubuntu 使用Debian 构建过程对于 ffmpeg。

从源代码构建确切地与 Debian 或 Ubuntu 一样,您需要使用“debmake”和“debuild”。有关完整文档,请参阅“Debian 维护者指南” (2019-03-26) 教程。

“debmake” 命令不会从源代码“制作”,而是修改源代码。“debuild” 命令会执行制作(但不是直接使用“make”,而是使用“dpkg-buildpackage”)。

从源代码构建的通常方法:

$ tar -xzmf debhello-0.0.tar.gz
$ cd debhello-0.0
$ make
$ make install

Debian从来源构建的方式:

$ tar -xzmf debhello-0.0.tar.gz
$ cd debhello-0.0
$ debmake
  ... manual customization
$ debuild
  ...

您可以使用以下方式获取源代码并构建依赖项:

sudo apt-get source ffmpeg
sudo apt-get build-dep ffmpeg

查看 Ubuntu 的apt-get 帮助有关使用该命令的详细信息。

如果你希望最终的构建结果相似的安装软件包后,使用“debmake”然后修改目录中的文件。进行修改后(不破坏任何内容),键入“debuild”以创建相似的可执行文件(包含您添加或删除的功能)。高级示例这种黑客攻击也是可用的,请参阅维护人员指南(从这个答案顶部开始的第三个链接)。

先尝试一个简单的示例(不做修改),除非你对上述说明感到满意。另请参阅Debian 构建教程 Wiki

我们的超级用户网站上还有针对 Debian 的解释:如何在 Debian 上安装 FFmpeg?

相关内容