【问题标题】:Ffmpeg compilation fails due to undefined symbol _x264_encoder_open_112 for architecture x86_64由于架构 x86_64 的未定义符号 _x264_encoder_open_112 导致 Ffmpeg 编译失败
【发布时间】:2011-09-23 07:41:44
【问题描述】:

我正在从源代码在 Snow Leopard 上编译 ffmpeg。使用 Macport 不是一个选项,因为我在 ffmpeg 中有一些自定义修改。 make 命令是:

$ ./configure --enable-gpl --enable-libmp3lame --enable-static \
            --disable-shared --enable-libx264 --enable-pthreads \
            --disable-doc --enable-avfilter
$ make

错误:

CC  ffplay.o
ffplay.c: In function ‘SDL_main’:
ffplay.c:3157: warning: assignment discards qualifiers from pointer target type
LD  ffplay_g
Undefined symbols for architecture x86_64:
  "_x264_encoder_open_112", referenced from:
      _X264_init in libavcodec.a(libx264.o)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [ffplay_g] Error 1

我已经从源代码编译了 libx264,一切正常。

$ cd x264-snapshot-20101228-2245; ./configure && make && sudo make install

...它包含符号“_x264_encoder_open_112”

$ nm ./libx264.a | grep _x264_encoder_open_112
0000000000003ef0 T _x264_encoder_open_112
000000000000d7b0 S _x264_encoder_open_112.eh

可能出了什么问题?

【问题讨论】:

  • 你解决过这个问题吗?我有完全相同的问题...
  • @beardedd 我没有准确的答案,但我必须继续重建库。我猜是macport有冲突。因此,您可能希望暂时删除这些库以强制 gcc 从 /usr 而不是 /opt 中选择 x264.a。随时通知我们!

标签: gcc ffmpeg ld undefined-symbol


【解决方案1】:

尝试使用 --enable-static 配置 x264。

我遇到了类似的问题,这对我来说是一个解决方案。

【讨论】:

  • 嗨@weekens,恐怕这不起作用,因为x264的配置不接受--enable-static。 $ ./configure --enable-static Unknown option --enable-static, ignored
  • @Saptarshi,这很奇怪,它以前对我有用。尝试从 Github 获取我的分支,只是为了检查它是否有效。 git clone git://github.com/weekens/x264-devel.git
  • 你说得对——来自git://git.videolan.org/x264.git 的最新源确实支持 --enable-static 选项。我一直在使用旧快照,这是造成混乱的根源。但是,使用 --enable-static 并不能解决我的问题。这是意料之中的,因为我已经有一个静态的 .a 库。
【解决方案2】:

/opt/local/lib/usr/lib 中类似名称的库之间存在冲突。前者由 Macport 维护,后者是我自己的开发区。由于我想使用后一个位置,我不得不删除/临时重命名/opt/local/lib 中的位置,以强制 gcc 从/usr/lib 中提取它们

在你的情况下,路径可能会有所不同,但你明白了。

如果你有更简洁的方法来实现这一点,我会全力以赴

【讨论】:

  • 我遇到了同样的问题,我只是在执行 ./configure 时从路径中删除了 /opt/local/lib,解决了问题。构建完成后,我把它放回了我的路径。
【解决方案3】:

我将为遇到此问题的 Mac OSX 上的 Homebrew 用户添加:

我在 /usr/lib 中还有额外的 libx264 库,我必须删除它们。

这导致使用brew install ffmpeg --use-clangbrew install ffmpeg --use-gcc 构建ffmpeg 时出现此错误:

LD  libavcodec/libavcodec.53.dylib
AR  libavcodec/libavcodec.a
Undefined symbols for architecture x86_64:
  "_x264_bit_depth", referenced from:
      _X264_init_static in libx264.o
      _X264_frame in libx264.o
  "_x264_picture_init", referenced from:
      _X264_frame in libx264.o
  "_x264_param_default_preset", referenced from:
      _X264_init in libx264.o
  "_x264_param_apply_fastfirstpass", referenced from:
      _X264_init in libx264.o
  "_x264_param_apply_profile", referenced from:
      _X264_init in libx264.o
  "_x264_encoder_open_120", referenced from:
      _X264_init in libx264.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [libavcodec/libavcodec.53.dylib] Error 1

额外的文件是:

/usr/lib/libx264.79.dylib
/usr/lib/libx264.a
/usr/lib/libx264.dylib

但是,这些版本可能会有所不同。移除后,构建成功。

在这里留下这个答案是因为试图找到与 libavcodec 的连接失败非常令人困惑。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-03
    • 2013-09-16
    • 2017-03-03
    • 2021-06-27
    • 2013-11-03
    相关资源
    最近更新 更多