4

I am compiling ffmpeg on Snow Leopard from source. Using Macport is not an option since I have some custom modification in ffmpeg. The make commands are:

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

The error:

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

I have compiled libx264 from source, which went fine.

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

... and it contains the symbol "_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

What might be going wrong?

S B
  • 8,134
  • 10
  • 54
  • 108
  • did you ever resolve this? I am having the exact same issue... – beardedd Jul 08 '11 at 00:43
  • @beardedd I don't have a precise answer but I had to proceed by rebuilding the libraries. I guess that there was a conflict from macport. So, you might want to temporarily remove those libs to force gcc to pick x264.a from `/usr` and not `/opt`. Keep us posted! – S B Jul 11 '11 at 09:58

3 Answers3

3

There was a conflict between similarly named libs from /opt/local/lib and /usr/lib. The former is maintained by Macport and the latter was my own dev area. Since I wanted to use the latter location, I had to remove / temporarily rename the ones in /opt/local/lib to force gcc to pick them up from /usr/lib

In your case, the paths may vary, but you get the idea.

If you have a cleaner way to achieve this, I am all ears

S B
  • 8,134
  • 10
  • 54
  • 108
  • 2
    I had the same problem and I just removed /opt/local/lib from my path while I did ./configure, solved the problem. After building I put it back in my path. – dcoffey3296 Jun 10 '12 at 03:14
0

Try to configure x264 with --enable-static.

I had a similar problem, and that was a solution for me.

weekens
  • 8,064
  • 6
  • 45
  • 62
  • Hi @weekens, I am afraid this does not work because x264's configure does not accept --enable-static. `$ ./configure --enable-static Unknown option --enable-static, ignored` – S B Jun 27 '11 at 09:02
  • @Saptarshi, that is strange, it was working for me before. Try taking my branch from Github, just to check if it works. `git clone git://github.com/weekens/x264-devel.git` – weekens Jun 27 '11 at 10:19
  • You are right - the latest source from `git://git.videolan.org/x264.git` indeed supports the --enable-static option. I had been using an old snapshot, which was the source of confusion. However, using --enable-static does not solve my problem. This is expected because I already had a static .a library. – S B Jun 29 '11 at 09:08
0

I'm going to add for users of Homebrew on Mac OSX having this issue:

I had extra libx264 libs in /usr/lib as well that I had to remove.

This resulted in this error in building ffmpeg with brew install ffmpeg --use-clang or brew install ffmpeg --use-gcc:

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

The extra files were:

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

However these versions may vary. After removal, the build succeeded.

Leaving this answer here because it was very confusing trying to find the connection to libavcodec failing.

trisweb
  • 8,814
  • 3
  • 32
  • 22