How To compile Librespot for Orange Pi or Kernel prior 3.9

Librespot is a nice piece of software enabling Linux devices to act as Spotify targets. Just like newer AV Receivers etc. It was developed by Paul Liétar after Spotify abandoned Libspotify.

On devices with modern Linux Kernels (3.9 onwards) Librespot works without any problems, but if you try to use it with older Kernels and use the discovery feature (no User/Pass required while starting Librespot) you might run into an error.

The error could look something like this:

INFO:librespot: librespot ddfc28f (2017-08-04). Built on 2017-08-07. Build ID: N5RcEuis thread 'main' 
panicked at 'calledResult::unwrap()on anErrvalue: Error { repr: Os { code: 92, message: "Protocol not 
available" } }', /checkout/src/libcore/result.rs:860 note: Run withRUST_BACKTRACE=1for a backtrace.

This happens because the used mdns solutions tries to use the Kernel Option SO_REUSEPORT which was introduced in Kernel Version 3.9. That could be a problem for you if you use for example an Orange Pi with the Mainline Kernel, because that ist stuck at Version 3.4 (rediculous).

The good thing is you can build a Version of Librespot yourself which does not have that problem. The user jr01 pointed me in the right direction Github Issue.

It is not very complicated, but do yourself a favour and try not to build it using your Orange Pi. It will take ages, if it ever finishes. Tried it for four hours an than gave up. Just use a Linux box or a suitable VM.

Because we will use the Docker Script provided by Paul the only thing you need is a Linux Box with Docker and git. I will not explain how to install Linux or Docker, there are tons of guides for this out there.

Once you have installed these things it is pretty easy.

First of all clone the Librespot Repo as well as the rust-mdns Repo from Github:

git clone https://github.com/plietar/librespot.git
git clone https://github.com/plietar/rust-mdns.git

Now we must „patch“ rust-mdns so it does not use the SO_REUSEPORT call. This is quiet simple. Go to rust-mdns->src->address_family.rs and search for the line that says .reuse_port(true)? and simply delete that line. Dont forget to save the file.

Move the whole rust-mdns folder to the librespot folder. Now change into the librespot folder and edit the file Cargo.toml. Under [dependencies] search for the line mdns = { git = „https://github.com/plietar/rust-mdns“ } an delete it. Scroll a bit back up and add the following lines before the [dependencies]- block:

[dependencies.mdns]
path = "mdns"

That was it. So we patched out the Reuse Port call and than told cargo that it should use the local patched Version of rust-mdns instead of the github Version.

Now we can use docker to compile librespot for it. Easy now, you only need to be inside the librespot folder for it:

docker build -t librespot-cross -f contrib/Dockerfile .
docker run -v /tmp/librespot-build:/build librespot-cross

After a couple of minutes you should be able to collect librespot from /tmp/librespot-build

That build should be able to be used on a variety of devices which do not ship with modern Kernels.
Have fun

3 Gedanken zu „How To compile Librespot for Orange Pi or Kernel prior 3.9“

  1. Thanks for your article. Unfortunately building fails with:

    + cargo build –release –no-default-features –features alsa-backend
    error: failed to parse manifest at `/src/Cargo.toml`

    Caused by:
    the given version requirement is invalid

  2. Your trick (clone and modify rust-mdns) worked for me when performing it in the librespot directory from a checked out raspotify. Thanks again.

  3. Thank you!

    For raspotify the instructions are close enough that I could adapt and use..

    Newer librespotify do not have the dependency as you described.. I found mdns under librespotify/connect/Cargo.toml

    but once you know what you are looking for its all good 🙂

Schreibe einen Kommentar zu Willem-Jan de Hoog Antworten abbrechen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert