Plugin build failure on OS X 10.7 (libADM_ae_twolame.dylib) with patch

Started by nieder, September 07, 2012, 02:19:53 PM

Previous topic - Next topic

nieder

I'm building avidemux 2.5.6 on OS X 10.7 (not using Homebrew; I'm trying to package this for Fink) and am running into this build failure:


Linking CXX shared library libADM_ae_twolame.dylib
cd /sw/build.build/avidemux-2.5.6-3/avidemux_2.5.6/pluginbuild/ADM_audioEncoders/twolame && /sw/bin/cmake -E cmake_link_script CMakeFiles/ADM_ae_twolame.dir/link.txt --verbose=1
/sw/opt/llvm-3.1/bin/clang++  -O3 -DNDEBUG -shared  -L/sw/lib -o libADM_ae_twolame.dylib -install_name /sw/build.build/avidemux-2.5.6-3/avidemux_2.5.6/pluginbuild/ADM_audioEncoders/twolame/libADM_ae_twolame.dylib CMakeFiles/ADM_ae_twolame.dir/audioencoder_twolame.cpp.o -L/sw/build.build/avidemux-2.5.6-3/avidemux_2.5.6/finkbuild/lib ADM_libtwolame/libADM_libtwolame.a -lADM_coreAudio -lADM_coreUI -lADM_core
Undefined symbols for architecture x86_64:
  "_buffer_putbits", referenced from:
      _encode_frame in libADM_libtwolame.a(twolame.c.o)
      _write_header in libADM_libtwolame.a(encode.c.o)
      _write_bit_alloc in libADM_libtwolame.a(encode.c.o)
      _write_scalefactors in libADM_libtwolame.a(encode.c.o)
      _write_samples in libADM_libtwolame.a(encode.c.o)
ld: symbol(s) not found for architecture x86_64
clang-3: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [ADM_audioEncoders/twolame/libADM_ae_twolame.dylib] Error 1
make[1]: *** [ADM_audioEncoders/twolame/CMakeFiles/ADM_ae_twolame.dir/all] Error 2


"nm ADM_libtwolame/libADM_libtwolame.a" indicates that the symbol _buffer_putbits is not defined in the static library.

Debian seems to have run into this problem and it looks to be a C99 issue (I'm building with clang, which is the default compiler on OS X)
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=416855

Based on the patch there, if I modify ADM_libtwolame/bitbuffer.c like this:

--- plugins/ADM_audioEncoders/twolame/ADM_libtwolame/bitbuffer.c 2010-05-15 11:55:35.000000000 -0400
+++ plugins/ADM_audioEncoders/twolame/ADM_libtwolame/bitbuffer.c 2012-09-07 10:10:36.000000000 -0400
@@ -69,7 +69,7 @@
}

/*write N bits into the bit stream */
-inline void buffer_putbits (bit_stream * bs, unsigned int val, int N)
+extern inline void buffer_putbits (bit_stream * bs, unsigned int val, int N)
{
static const int putmask[9] = { 0x0, 0x1, 0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff };
register int j = N;


then libADM_ae_twolame.dylib and the rest of the plugins build successfully.

nibbles