【问题标题】:How to correctly link ffmpeg to static build "g++ -static"?如何正确地将 ffmpeg 链接到静态构建“g++ -static”?
【发布时间】:2014-07-21 22:39:15
【问题描述】:

我想在将项目编译到静态可执行文件时链接 ffmpeg 的静态构建。我使用以下命令:

g++ -O2 -static -o myBin myBin-myBin.o -lm -lpthread someotherlibraries.a 
/path/to/libavformat.a /path/to/libavcodec.a

但得到以下错误列表,尽管我使用 --disable-libopus 配置了 ffmpeg:

libavcodec/opusdec.c:376: error: undefined reference to 'swr_is_initialized'
libavcodec/opusdec.c:222: error: undefined reference to 'swr_is_initialized'
libavcodec/opusdec.c:163: error: undefined reference to 'swr_init'
libavcodec/opusdec.c:169: error: undefined reference to 'swr_convert'
libavcodec/opusdec.c:236: error: undefined reference to 'swr_convert'
libavcodec/opusdec.c:117: error: undefined reference to 'swr_convert'
libavcodec/opusdec.c:408: error: undefined reference to 'swr_close'
libavcodec/opusdec.c:557: error: undefined reference to 'swr_close'
libavcodec/opusdec.c:579: error: undefined reference to 'swr_free'
libavcodec/opusdec.c:629: error: undefined reference to 'swr_alloc'

我在这里做错了什么?

【问题讨论】:

    标签: ffmpeg g++ static-libraries static-linking


    【解决方案1】:

    -lswresample 是导致错误的缺失标志

    【讨论】:

      【解决方案2】:

      您必须为静态构建设置额外的链接器,例如 -lz。但是,如果可行,为什么不直接进行动态链接呢?

      【讨论】:

      • 您能提供我必须设置的确切链接器吗?我需要它是静态的,因为我想在不同的机器上使用这个可执行文件。
      猜你喜欢
      • 2012-02-23
      • 1970-01-01
      • 2016-01-20
      • 1970-01-01
      • 2020-05-10
      • 1970-01-01
      • 2023-01-24
      • 2012-07-04
      • 2020-06-17
      相关资源
      最近更新 更多