Press "Enter" to skip to content

How to compile SoX

In the download area you can find the .tar.gz archives of the source code used to compile the binaries available for download on this website:

  • sox.tar.gz this version has opus support disabled because it causes some problems on macOS and FreeBSD and is therefore compatible with all O.Ss.

IMPORTANT: the GitHub repository with updated source code and more information about this project is as always at mansr/sox

Linux

Every Linux distribution has its own package manager and its own packages, the following applies to Ubuntu but it can easily tweaked to work elsewhere. Install the dependencies first:

sudo apt-get install libopencore-amrnb-dev libopencore-amrwb-dev libao-dev libflac-dev libmp3lame-dev libtwolame-dev libltdl-dev libmad0-dev libid3tag0-dev libvorbis-dev libpng-dev libsndfile1-dev libwavpack-dev

Run the following:

autoreconf -i
./configure
make

If you wish to compile a static linked binary : Coming soon …

FreeBSD

You have three choices to install the dependencies:

1- Download each tarball from its website (only the ones you need) and compile them all:

OpencoreAMR-NB/WB http://sourceforge.net/projects/opencore-amr
AMR-NB/WB http://www.penguin.cz/~utx/amr
AO http://xiph.org/ao
FLAC http://flac.sourceforge.net
LADSPA http://www.ladspa.org
Lame MP3 encoder http://lame.sourceforge.net
Twolame MP2 enc. http://www.twolame.org
libltdl http://www.gnu.org/software/libtool
MAD MP3 decoder http://www.underbit.com/products/mad
MP3 ID3 tags https://sourceforge.net/projects/mad/files/libid3tag/
Magic http://www.darwinsys.com/file
Ogg Vorbis http://www.vorbis.com
Opus http://www.opus-codec.org/
PNG http://www.libpng.org/pub/png zlib
Sndfile http://www.mega-nerd.com/libsndfile
WavPack http://www.wavpack.com

2- Use ports <- Recommended!

audio/opencore-amr
audio/libao
audio/flac
audio/ladspa
audio/lame
audio/twolame
devel/libltdl
audio/libmad
audio/libid3tag
cad/magic
audio/libvorbis
graphics/png
audio/libsndfile
audio/wavpack

3- Use packages <- Fastest

pkg install opencore-amr libao flac ladspa twolame libltdl libmad libid3tag magic libvorbis png libsndfile wavpack

P.S. lame is not included in the package list because you need to compile it from ports.

As you can see I haven’t included opus in the list above due to some issues with this audio codec in O.Ss different from Linux.

Compiling

For a standard configuration:

autoreconf -i
./configure
make

If you want a static linked binary just take all the libraries you compiled before with extension *.a and copy them to a folder ex. /ex/folder and then:

autoreconf -i
./configure CFLAGS='-static' LDFLAGS='-static -L/ex/folder' --disable-shared --with-distro='FreeBSD 11'
make

macOS

Just use Brew -> https://brew.sh/

brew install opencore-amr libao flac two-lame libtool mad libid3tag libmagic libvorbis libpng libsndfile wavpack lame

Compiling

For a standard configuration:

autoreconf -i
./configure
make

If you want a static linked binary just take all the libraries you compiled before with extension *.a and copy them to a folder ex. /ex/folder, then run:

autoreconf -i
./configure LDFLAGS='-static -L/ex/folder' --disable-shared --with-distro='macOS 10.12 Sierra'
make

5 Comments

  1. G. Bader G. Bader 29 settembre 2017

    Dear Simone,

    I tried to compile SOX on my ARMv7 NAS but I get one error during the make process:
    CCLD libsox.la
    .libs/libsox_la-mp3.o:(.data+0x4): undefined reference to `mad_stream_buffer’
    .libs/libsox_la-mp3.o:(.data+0x10): undefined reference to `mad_stream_skip’
    .libs/libsox_la-mp3.o:(.data+0x1c): undefined reference to `mad_stream_sync’
    .libs/libsox_la-mp3.o:(.data+0x28): undefined reference to `mad_stream_init’
    .libs/libsox_la-mp3.o:(.data+0x34): undefined reference to `mad_frame_init’
    .libs/libsox_la-mp3.o:(.data+0x40): undefined reference to `mad_synth_init’
    .libs/libsox_la-mp3.o:(.data+0x4c): undefined reference to `mad_frame_decode’
    .libs/libsox_la-mp3.o:(.data+0x58): undefined reference to `mad_timer_add’
    .libs/libsox_la-mp3.o:(.data+0x64): undefined reference to `mad_synth_frame’
    .libs/libsox_la-mp3.o:(.data+0x70): undefined reference to `mad_stream_errorstr’
    .libs/libsox_la-mp3.o:(.data+0x7c): undefined reference to `mad_frame_finish’
    .libs/libsox_la-mp3.o:(.data+0x88): undefined reference to `mad_stream_finish’
    .libs/libsox_la-mp3.o:(.data+0x94): undefined reference to `mad_bit_read’
    .libs/libsox_la-mp3.o:(.data+0xa0): undefined reference to `mad_header_decode’
    .libs/libsox_la-mp3.o:(.data+0xac): undefined reference to `mad_header_init’
    .libs/libsox_la-mp3.o:(.data+0xb8): undefined reference to `mad_timer_count’
    .libs/libsox_la-mp3.o:(.data+0xc4): undefined reference to `mad_timer_multiply’
    collect2: error: ld returned 1 exit status
    make[1]: *** [Makefile:1236: libsox.la] Error 1
    make[1]: Leaving directory ‘/volume1/homes/Gerhard/LINUX/SOX/sox/src’
    make: *** [Makefile:654: all-recursive] Error 1

    Note that I did not find all the libraries mentioned on your page, because they are not provided within Entware-ng oPkg packet manager.

    Any help would be highly appreciated!
    Gerhard

    • Simone Simone 9 ottobre 2017

      Hi Gerhard, it seems that, as you said, you have not installed all the libraries that you need; in this specific case the mad library is missing. I really don’t know what kind of packages manager are you using so the only way is to compile the missing libraries; for example the source code of mad is downloadable here: https://sourceforge.net/projects/mad/files/libmad/0.15.1b/

      If you are looking for all the source codes of the libraries I have written them under the first point of the FreeBSD section of the guide.

  2. Takeshi Nakano Takeshi Nakano 26 dicembre 2017

    This article help me to save my time a lot! Thank you.
    One thing if I may, it will make it more helpful to add dh-autoreconf for needed package as apt command line for Ubuntu (I am using 17.10 server)

    • Simone Simone 27 dicembre 2017

      Hi Takeshi! I’m happy that this article has been helpful for you!, All the best

Rispondi

%d blogger hanno fatto clic su Mi Piace per questo: