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

15 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

  3. Fabio Fabio 25 Agosto 2018

    Hi Simone,

    how do i get to the folder where replace SOX on my qnap NAS? what’s the version of SOX I have to actually download for a nap NAS

    • Simone Simone 16 Agosto 2021

      Can you be more descriptive? The latest is hosted on the official sourceforge repo.

      • Rafa Rafa 17 Agosto 2021

        Sure: “resample_soxr standalone resampler in 64-bit operation using soxr library.”

        Description taken from: https://bitbucket.org/frank_l/frankl_stereo/src/master/

        If you look at the graphs over at the SRC Comparisons page, you’ll see that “Frankl resample_soxr” beats everything!: https://src.infinitewave.ca/

        Also, would you consider updating the Windows Repo. binaries to 64/64-AVX?

        Thank you!

        • Simone Simone 17 Agosto 2021

          This Is soxr, the reample library. Not sox. These are two different things.

          • Rafa Rafa 18 Agosto 2021

            I see, thank you for clearing that up!

            By the way, for some reason, my comment was duplicated, could you please delete the extra one?

  4. Fabio Fabio 8 Settembre 2021

    Hi there,
    this is the message on the settings tab of my LMS:”Your player can play the DSD format, the SOX version in use not. See: http://www.audiodigitale.eu
    LMS is running on a Qnap ts-251 while got a futro as player, so how to change SOX version over there? which one I’ve should download?
    sorry if a silly question
    cheers

    • Simone Simone 9 Settembre 2021

      You can try the sox-Linux-AMD64 and see if that works

  5. Chethana Chethana 22 Giugno 2023

    when I try ./play monkey.wav this is the error : FAIL sox: No input filenames specified
    how can /i sort this ? Any help is appreciated

Rispondi

Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.

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