vorbis-tools ogg123の静的バイナリビルドを作成するには?

vorbis-tools ogg123の静的バイナリビルドを作成するには?

実行するにはogg123(ogg vorbisからwavをインポートする)、静的ビルドをインポートするか(見つからない)コンパイルする必要があります。 Amazon Linux(現在のAWS Lambdaバージョンと同じ)でこれを試しました。

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

結果ogg123のファイルサイズは288Kですが、ファイルを別のAmazon Linuxにコピーして実行しようとすると、次のエラーが発生します。 error while loading shared libraries: libvorbisfile.so.3: cannot open shared object file: No such file or directory

ベストアンサー1

wavでデコードしたい場合は、代わりにユーティリティをogg vorbis使用してください(より多くの依存関係があります)。oggdecogg123

「静的」バージョンをビルドするには、まずライブラリの静的バージョンを次のようにビルドするoggdec必要があります。libogglibvorbis

#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

これでoggdecvorbis-toolsをビルドしてlibogg静的にリンクできます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

あなたはそれを使用することができますLDD、新しく構築されたバイナリoggdecの依存関係のリストを確認してください。

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)

結果のバイナリは、一部のシステムライブラリ(特に「libc」および「libm」)への依存関係をまだ公開しているため、実際には完全に「静的」ではありませんが、「Amazon Linux」で実行するのに適している必要があります。

おすすめ記事