2

In order to run ogg123 (for getting wav from ogg vorbis) I need to get (not found) or compile static build. I tried this on Amazon Linux (the same version as current AWS Lambda):

./configure --disable-shared --enable-static
make LDFLAGS=-lm SHARED=0 CC='gcc -static'

Produced ogg123 filesize is 288K but when I copied that file to another Amazon Linux and tried to run I get error while loading shared libraries: libvorbisfile.so.3: cannot open shared object file: No such file or directory

Vitaly Zdanevich
  • 359
  • 1
  • 2
  • 15
  • It looks like this wasn't static build. One comment, it might be better to also supply `-fPIC` gcc flag although that won't solve this particular problem. Can you post a link to the source code that you're trying to compile? – bytefire Oct 18 '17 at 14:44
  • The source code of `ogg123` is here https://github.com/xiph/vorbis-tools/tree/master/ogg123 – Vitaly Zdanevich Oct 18 '17 at 15:47

1 Answers1

1

If you only want to decode wav from ogg vorbis, you can simply use oggdec utility to do that, instead of ogg123 (which has more dependencies).

To build a "static" version of oggdec, you will first need to build static versions of libogg and libvorbis libraries, like this:

#Create staging directory
STAGING=$HOME/staging/vorbis-tools
mkdir -p $STAGING

#Sources
SRC=$STAGING/src
mkdir -p $SRC

#Build artifacts
OUT=$STAGING/build
mkdir -p $OUT

#Build a static version of "libogg"
wget downloads.xiph.org/releases/ogg/libogg-1.3.1.tar.xz -qO-|tar -C $SRC -xJ
pushd $SRC/libogg*/
./configure --prefix=$OUT --disable-shared
make install
popd

#Build a static version of "libvorbis"
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.xz -qO-|tar -C $SRC -xJ
pushd $SRC/libvorbis*/
./configure --prefix=$OUT LDFLAGS="-L$OUT/lib" CPPFLAGS="-I$OUT/include" --disable-shared
make install
popd

Now you can build oggdec (vorbis-tools), statically linked to libogg and libvorbis:

#Build "vorbis-tools"
wget downloads.xiph.org/releases/vorbis/vorbis-tools-1.4.0.tar.gz -qO- | tar -C $SRC -xz
pushd $SRC/vorbis-tools*/
./configure LDFLAGS="-L$OUT/lib" CPPFLAGS="-I$OUT/include"
make
popd

You can use ldd, to check the list of dependencies for your newly built oggdec binary:

ldd $SRC/vorbis-tools*/oggdec/oggdec

linux-vdso.so.1 (0x00007ffc85792000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fbcba839000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fbcba48e000)
/lib64/ld-linux-x86-64.so.2 (0x00007fbcbab3a000)

The resulting binary is not really fully "static", as it still exposes dependency on some system libraries (in particular "libc" and "libm"), but that should be just fine for running it under "Amazon Linux".

zeppelin
  • 3,782
  • 10
  • 21