undefined reference to `x264_encoder_open_125'
Asked Answered
S

3

8

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?

Schizopod answered 7/8, 2012 at 2:26 Comment(2)
You need to ensure you also have x264 compiled from source properly. Usually seen this if either x264 wrong version is compiled or if there is clash between preinstalled version and a version you installed from source. Try setting LD_LIBRARY_PATH to the directory where libx264 is supposed to be.Elamite
Did you follow the guide word-for-word? As user1559108 mentioned, you probably have two different versions of x264 installed simultaneously (this includes the libx264-dev package).Attainder
W
9

This is a typical problem for people who already have x264 installed through the package management system. You can solve this in at least 2 ways:

  1. Uninstall the already existing x264 from your system, through the package management system:

    # apt-get remove x264
    

    and compile your new x264 from source

  2. Don't uninstall the x264 package, but compile your new x264 and then compile your ffmpeg, telling it to use that newly compiled x264 library, by specifying that directory where your compiled x264 library is, using the mentioned LD_LIBRARY_PATH environment variable:

    LD_LIBRARY_PATH=/path/to/my/compiled/x264/library ./configure --enable-libx264 ...
    

More info can be found on these links:

Walkout answered 18/6, 2013 at 16:56 Comment(3)
for me something like this worked (with macports installed into /opt/rdp_project_local with x264 installed there): `CFLAGS="-I/opt/rdp_project_local/include" LDFLAGS="-L/opt/rdp_project_local/lib" ./configure ...Estrellaestrellita
You might also consider PKG_CONFIG_PATH=/path/to/my/compiled/x264/library ./configure ...Messuage
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 have been placed in /usr/local/lib or the like.Betsybetta
G
1

add the header and lib path

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

Globin answered 15/10, 2018 at 6:41 Comment(0)
B
0

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.

Betsybetta answered 17/10, 2020 at 21:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.