对`x264_encoder_open_125'的未定义引用

时间:2012-08-07 02:26:15

标签: ffmpeg ubuntu-12.04

在Ubuntu 12.04上安装ffmpeg时

我收到以下错误

libavcodec/libavcodec.a(libx264.o): In function `X264_init':
/root/ffmpeg/libavcodec/libx264.c:492: undefined reference to `x264_encoder_open_125'
collect2: ld returned 1 exit status
make: *** [ffmpeg_g] Error 1

我遵循了给出的指示 http://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuide

有人对此错误有所了解吗?

3 个答案:

答案 0 :(得分:9)

对于已经通过包管理系统安装了x264的人来说,这是一个典型问题。您可以通过至少两种方式解决此问题:

  1. 通过包管理系统从系统中卸载现有的x264:

    # apt-get remove x264
    

    compile your new x264 from source

  2. 不要卸载x264软件包,而是compile your new x264然后compile your ffmpeg,告诉它使用新编译的x264库,通过指定编译的x264库所在的目录,使用提到的LD_LIBRARY_PATH环境变量:

    LD_LIBRARY_PATH=/path/to/my/compiled/x264/library ./configure --enable-libx264 ...
    
  3. 可在以下链接中找到更多信息:

答案 1 :(得分:0)

通常,该错误表示链接器拾取的库二进制文件libx264.so与头文件x264.h中的版本不匹配。请参见此头文件中的以下代码行:

/* Force a link error in the case of linking against an incompatible API version.
 * Glue #defines exist to force correct macro expansion; the final output of the macro
 * is x264_encoder_open_##X264_BUILD (for purposes of dlopen). */
#define x264_encoder_glue1(x,y) x##y
#define x264_encoder_glue2(x,y) x264_encoder_glue1(x,y)
#define x264_encoder_open x264_encoder_glue2(x264_encoder_open_,X264_BUILD)

该解决方案通常不需要自己构建libx264, 只需确保您正确安装了libx264-dev,而不会干扰/usr/local/lib之类的其他版本。

我在155版中遇到了相同的问题: undefined reference to 'x264_encoder_open_155'。 就我而言,这是因为我有/usr/lib/x86_64-linux-gnu的副本和不合适的libx264.so的副本(我自己制作了该副本,并在那里不整洁地复制了该副本)。 所以我要做的就是sudo apt-get install --reinstall libx264-dev

答案 2 :(得分:-1)

添加标题和库路径

gcc x264_test1.c -o x264_encoder -I/usr/local/include -L/usr/local/lib -lpthread -lm -lx264