I'm having trouble trying to build a static binary of ffmpeg - I've got almost the whole build working, with the exception of two libs - libvorbis and libmp3lame.

These two libs are failing during ./configure, specifically on undefined functions from the math.h / libm:


gcc -L/vol/build/lib -static -static-libstdc++ -static-libgcc -Wl,--as-needed -Wl,-z,noexecstack -I/vol/build/include -L/vol/build/lib -o /tmp/ffconf.UKKLGhCv/test /tmp/ffconf.UKKLGhCv/test.o -lvorbis -lm -logg -lstdc++ -lpthread -lexpat -ldl -lm --enable-libopencore-amrnb
/vol/build/lib/libvorbis.a(envelope.o): In function `_ve_envelope_init':
envelope.c:(.text+0x983): undefined reference to `_ZGVbN2v_sin'
envelope.c:(.text+0x9a9): undefined reference to `_ZGVbN2v_sin'
/vol/build/lib/libvorbis.a(lsp.o): In function `vorbis_lsp_to_curve':
lsp.c:(.text+0x650): undefined reference to `_ZGVbN2v_cos'
lsp.c:(.text+0x669): undefined reference to `_ZGVbN2v_cos'


gcc -L/vol/build/lib -static -static-libstdc++ -static-libgcc -Wl,--as-needed -Wl,-z,noexecstack -o /tmp/ffconf.dC4w1f5B/test /tmp/ffconf.dC4w1f5B/test.o -lmp3lame -lm -lstdc++ -lpthread -lexpat -ldl -lm --enable-libopencore-amrnb
/vol/build/lib/libmp3lame.a(psymodel.o): In function `init_s3_values':
psymodel.c:(.text+0x14d3): undefined reference to `_ZGVbN2v___exp_finite'
psymodel.c:(.text+0x14fa): undefined reference to `_ZGVbN2v___exp_finite'
/vol/build/lib/libmp3lame.a(psymodel.o): In function `psymodel_init':
psymodel.c:(.text+0xb62d): undefined reference to `_ZGVbN4vv___powf_finite'
psymodel.c:(.text+0xb677): undefined reference to `_ZGVbN4vv___powf_finite'
psymodel.c:(.text+0xb6c4): undefined reference to `_ZGVbN4vv___powf_finite'
psymodel.c:(.text+0xb711): undefined reference to `_ZGVbN4vv___powf_finite'
psymodel.c:(.text+0xb75b): undefined reference to `_ZGVbN4vv___powf_finite'
/vol/build/lib/libmp3lame.a(psymodel.o):psymodel.c:(.text+0xb7a2): more undefined references to `_ZGVbN4vv___powf_finite' follow
/vol/build/lib/libmp3lame.a(util.o): In function `fill_buffer':
util.c:(.text+0x28a6): undefined reference to `_ZGVbN2v_cos'
util.c:(.text+0x28cc): undefined reference to `_ZGVbN2v_cos'
util.c:(.text+0x28fb): undefined reference to `_ZGVbN2v_cos'
util.c:(.text+0x2921): undefined reference to `_ZGVbN2v_cos'
util.c:(.text+0x29cc): undefined reference to `_ZGVbN2v_sin'
util.c:(.text+0x29e8): undefined reference to `_ZGVbN2v_sin'

I can't figure out how to get these to sucessfully build. From what I understand, passing the -lm option should be enough, but apparently isn't. I checked for the presence of libm.a, which is located at /usr/lib/x86_64-linux-gnu/libm.a, I also tried to pass this directory in the -L flags, but no difference. The libs build fine when removing the -static flag, but the resulting binary is (duh) linked against libm.so.

Just in case, these are the flags I'm using to build the two libraries:

./configure --prefix=${CMAKE_BINARY_DIR} --disable-shared --disable-oggtest

./configure --prefix=${CMAKE_BINARY_DIR} --disable-shared

I'd appreciate any pointers on how to fix or debug this any further.

Edit: after playing around with it some more, it seems like the libm is getting linked in - when I remove the -lm flag, I'm getting a ton more undefined references - sin, cos, __pow_finite, etc. When I put it back in, most of these go away and only those mangled symbols, such as _ZGVbN4vv___powf_finite and _ZGVbN2v_cos remain.

  • These symbols may be indeed missing from libm. You could verify with: readelf -s [path-to-libm] | grep [symname] – valiano May 27 '18 at 21:43
  • I may be off but it seems these symbols are not in libm - they don't demangle well. They may be part of the library itself. Check this link: https://dev.solus-project.com/file/data/7dedblvkcdk5kmw3ltvn/PHID-FILE-27qhoqo6wsubrntfj2xc/D1210.diff – valiano May 27 '18 at 21:47

Well, I managed to solve it - googling the mangled symbols such as _ZGVbN2v_cos led me to this patch mentioning vector math, and in combination with ldd's output during dynamic linking mentioning libmvec, I realized that I might have to link that in as well.

For libmp3lame, it has to be linked in before libm:

gcc -L/vol/build/lib -static -o /tmp/ffconf.dC4w1f5B/test /tmp/ffconf.dC4w1f5B/test.o -lmp3lame -lmvec -lm

For libvorbis, the order of -lm and -lmvec doesn't matter, it builds either way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.