undefined reference to `x264_encoder_open_125'

Viewed 17121

While installing ffmpeg on Ubuntu 12.04

I am getting following error

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

I am following the instructions given at http://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuide

Do anyone have idea about this error?

3 Answers

add the header and lib path

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

Generally the error means that the library binary libx264.so picked up by the linker does not match the version in the header file x264.h. See the following lines of code in this header file:

/* 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)

The solution usually does not require building libx264 yourself, just make sure that you installed libx264-dev properly without interference with other versions, which may also be in /usr/local/lib or the like.

I had the same issue with version 155: undefined reference to 'x264_encoder_open_155'. In my case this was because I had in /usr/lib/x86_64-linux-gnu and unsuitable copy of libx264.so (which I had produced myself and uncleanly copied there). So all I had to do was sudo apt-get install --reinstall libx264-dev.

Related