Last active
December 28, 2025 20:17
-
-
Save spvkgn/60c12010d4cae1243dfee45b0821f692 to your computer and use it in GitHub Desktop.
Script to build a statically linked opus-tools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -eo pipefail | |
| # Script to build a statically linked version of opus-tools | |
| # | |
| # Release tarballs: | |
| # http://downloads.xiph.org/releases/opus/ | |
| # http://downloads.xiph.org/releases/ogg/ | |
| # http://downloads.xiph.org/releases/flac/ | |
| # | |
| # Build deps: | |
| # Debian/Ubuntu: apt install autoconf automake libtool-bin pkg-config git libarchive-tools wget | |
| # Alpine: apk add bash build-base coreutils grep wget tar xz autoconf automake libtool pkgconf git libarchive-tools | |
| BUILD_DIR=$PWD/build | |
| export PKG_CONFIG_PATH="$BUILD_DIR/lib/pkgconfig" | |
| export CFLAGS="-O3 -fno-strict-aliasing -march=native" | |
| ARCH=$(uname -m) | |
| SUFFIX="-static" | |
| get_sources() { | |
| SOURCES_URL=http://downloads.xiph.org/releases/ | |
| NAME=$1 | |
| case $NAME in | |
| *"opus"*) SOURCES_URL+="opus" ;; | |
| *"ogg"*) SOURCES_URL+="ogg" ;; | |
| *"flac"*) SOURCES_URL+="flac" ;; | |
| esac | |
| echo "Download $NAME sources" | |
| wget -qO- $SOURCES_URL |\ | |
| grep -Po "href=\"\K$NAME-(\d+\.)+\d+.*\.tar\.(gz|xz)(?=\")" | sort -V | tail -1 |\ | |
| xargs -I{} wget -qO- $SOURCES_URL/{} | bsdtar -x | |
| } | |
| mkdir -p "$BUILD_DIR" | |
| # build libogg | |
| get_sources libogg | |
| ( cd libogg-*/ | |
| autoreconf -fi && \ | |
| ./configure --prefix=$BUILD_DIR \ | |
| --disable-shared --enable-static \ | |
| --disable-dependency-tracking && \ | |
| make -j$(nproc) install ) | |
| # build FLAC | |
| get_sources flac | |
| ( cd flac-*/ | |
| autoreconf -fi && \ | |
| ./configure --prefix=$BUILD_DIR \ | |
| --disable-shared --enable-static \ | |
| --disable-dependency-tracking \ | |
| --disable-debug \ | |
| --disable-oggtest \ | |
| --disable-cpplibs \ | |
| --disable-doxygen-docs \ | |
| --with-ogg="$BUILD_DIR" && \ | |
| make -j$(nproc) install ) | |
| # build Opus | |
| get_sources opus | |
| ( cd opus-*/ | |
| [[ "$ARCH" =~ arm ]] && EXTRA_CONFIG_FLAGS=--enable-fixed-point | |
| autoreconf -fi && \ | |
| ./configure --prefix=$BUILD_DIR \ | |
| --disable-shared --enable-static \ | |
| --disable-dependency-tracking \ | |
| --disable-maintainer-mode \ | |
| --disable-doc \ | |
| --disable-extra-programs $OPUS_EXTRA_CONFIG_FLAGS && \ | |
| make -j$(nproc) install ) | |
| # build opusfile | |
| get_sources opusfile | |
| ( cd opusfile-*/ | |
| [[ "$ARCH" =~ arm ]] && EXTRA_CONFIG_FLAGS=--enable-fixed-point | |
| autoreconf -fi && \ | |
| ./configure --prefix=$BUILD_DIR \ | |
| --disable-shared --enable-static \ | |
| --disable-dependency-tracking \ | |
| --disable-maintainer-mode \ | |
| --disable-examples \ | |
| --disable-doc \ | |
| --disable-http $EXTRA_CONFIG_FLAGS && \ | |
| make -j$(nproc) install ) | |
| # build libopusenc | |
| get_sources libopusenc | |
| ( cd libopusenc-*/ | |
| autoreconf -fi && \ | |
| ./configure --prefix=$BUILD_DIR \ | |
| --disable-shared --enable-static \ | |
| --disable-dependency-tracking \ | |
| --disable-maintainer-mode \ | |
| --disable-examples \ | |
| --disable-doc && \ | |
| make -j$(nproc) install ) | |
| # build opus-tools | |
| git clone --depth 1 https://github.com/xiph/opus-tools.git | |
| ( cd opus-tools | |
| ./autogen.sh && \ | |
| sed -e 's/@LDFLAGS@/@LDFLAGS@ -all-static/' -i Makefile.in | |
| LDFLAGS="-Wl,-static -static -static-libgcc" \ | |
| ./configure --prefix=$BUILD_DIR \ | |
| --disable-dependency-tracking \ | |
| --disable-maintainer-mode | |
| make -j$(nproc) install ) | |
| if ls $BUILD_DIR/bin/opus* > /dev/null 2>&1 ; then | |
| for file in $BUILD_DIR/bin/opus* ; do | |
| cp $file $PWD/$(basename $file)$SUFFIX && \ | |
| strip $PWD/$(basename $file)$SUFFIX | |
| done | |
| fi |
I keep coming back to this script to try out latest version. However, when building opus-tools I get:
In file included from src/opusenc.c:71:
src/opusenc.c: In function ‘main’:
/tmp/build/include/opus/opusenc.h:134:63: error: implicit declaration of function ‘__opus_check_int’; did you mean ‘opus_check_int’? [-Wimplicit-function-declaration]
134 | #define OPE_SET_MUXING_DELAY(x) OPE_SET_MUXING_DELAY_REQUEST, __opus_check_int(x)
| ^~~~~~~~~~~~~~~~
src/opusenc.c:946:30: note: in expansion of macro ‘OPE_SET_MUXING_DELAY’
946 | ret = ope_encoder_ctl(enc, OPE_SET_MUXING_DELAY(max_ogg_delay));
| ^~~~~~~~~~~~~~~~~~~~
/tmp/build/include/opus/opusenc.h:134:63: warning: nested extern declaration of ‘__opus_check_int’ [-Wnested-externs]
134 | #define OPE_SET_MUXING_DELAY(x) OPE_SET_MUXING_DELAY_REQUEST, __opus_check_int(x)
| ^~~~~~~~~~~~~~~~
src/opusenc.c:946:30: note: in expansion of macro ‘OPE_SET_MUXING_DELAY’
946 | ret = ope_encoder_ctl(enc, OPE_SET_MUXING_DELAY(max_ogg_delay));
| ^~~~~~~~~~~~~~~~~~~~
/tmp/build/include/opus/opusenc.h:145:59: error: implicit declaration of function ‘__opus_check_int_ptr’; did you mean ‘opus_check_int_ptr’? [-Wimplicit-function-declaration]
145 | #define OPE_GET_NB_STREAMS(x) OPE_GET_NB_STREAMS_REQUEST, __opus_check_int_ptr(x)
| ^~~~~~~~~~~~~~~~~~~~
src/opusenc.c:967:30: note: in expansion of macro ‘OPE_GET_NB_STREAMS’
967 | ret = ope_encoder_ctl(enc, OPE_GET_NB_STREAMS(&data.nb_streams));
| ^~~~~~~~~~~~~~~~~~
/tmp/build/include/opus/opusenc.h:145:59: warning: nested extern declaration of ‘__opus_check_int_ptr’ [-Wnested-externs]
145 | #define OPE_GET_NB_STREAMS(x) OPE_GET_NB_STREAMS_REQUEST, __opus_check_int_ptr(x)
| ^~~~~~~~~~~~~~~~~~~~
src/opusenc.c:967:30: note: in expansion of macro ‘OPE_GET_NB_STREAMS’
967 | ret = ope_encoder_ctl(enc, OPE_GET_NB_STREAMS(&data.nb_streams));
| ^~~~~~~~~~~~~~~~~~
make[1]: *** [Makefile:886: src/opusenc-opusenc.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/tmp/opus-tools'
make: *** [Makefile:1108: install-recursive] Error 1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using
githttps://gist.github.com/guest271314/12a93ff775590867c0862be45fc71161