Skip to content
fivebanger edited this page Oct 25, 2024 · 41 revisions

General instructions

The following is additional to COMPILING.md, which you should read first.

macOS

If you are building librespot on macOS, the Homebrew-provided Rust may fail due to the way in which Homebrew installs it. In this case, uninstall the Homebrew version of Rust and use rustup.

Linux

On Linux, a kernel version of 3.9 or higher is required. For info on compiling for older kernels see: Compile-librespot-for-kernel-prior-3.9

Linux/macOS/Windows

The usage of aws-lc-sys as a dependency may require additional steps in order to compile for different target systems. Further reading is recommended, especially when compiling for Windows.

Features

The default for librespot is to build with Rodio for audio playback. However you can use cargo's feature flags to change these defaults like:

cargo build --release --no-default-features --features alsa-backend

Here is a full list of available "features" and a short description.

Flag Feature
rodio-backend Audio playback using WASAPI/CoreAudio/ALSA via Rodio
alsa-backend Audio playback using ALSA
portaudio-backend Audio playback using PortAudio
pulseaudio-backend Audio playback using PulseAudio
jackaudio-backend Audio playback using JACK
rodiojack-backend Audio playback using JACK via Rodio. This backend is only supported on Linux as is
sdl-backend Audio playback using SDL2
gstreamer-backend Audio playback using GStreamer
with-dns-sd LAN discovery using Avahi or Bonjour daemon instead of responding on DNS-SD requests itself. Does not work on Windows. For more details see below.

Dependencies

Rodio is a high-level audio library built on top of CPAL. It is the default as it does not require any non-Rust dependencies on Windows or macOS, and is able to use the native audio engines. On Linux the dependencies are the same for the ALSA backend.

For other backends, please read COMPILING.md for their dependencies and how to install them.

GStreamer on Windows

On Windows, you can configure your build toolchain using one of two approaches: the Visual C++ toolchain or the MinGW64 toolchain. This Wiki does not currently document how to use the Visual C++ toolchain. The MinGW64 toolchain is quite straightforward.

For MinGW64, you should do the following things:

  • Install MSYS2 from here.
  • Install Rust within MSYS's environment (bash) using pacman -S mingw-w64-x86_64-rust.
  • Install GStreamer and dependencies within MSYS using pacman -S mingw-w64-x86_64-gst-plugins-base mingw-w64-x86_64-gst-plugins-good mingw-w64-x86_64-gst-plugins-bad mingw-w64-x86_64-gst-plugins-ugly mingw-w64-x86_64-gstreamer mingw-w64-x86_64-gcc
  • Build librespot normally using cargo.
  • Copy the librespot.exe binary into the bin directory where all your MinGW DLLs are. You may have to copy some DLLs as well.
  • If librespot.exe crashes or fails to launch due to missing DLLs, you can always copy them from wherever they are in the MinGW/MSYS folder structure into the same directory as librespot.

It is also possible to use third-party GStreamer builds in many cases, because Windows doesn't care whether compiled .DLL files were built with MinGW or Visual C++. There are official GStreamer binaries for Windows available here and you can drop the DLLs into the same directory as your librespot.exe to have it pick them up.

As a final option, in case commonly available builds don't have the plugins you're looking for, you can build GStreamer from source. By far, the easiest way to build GStreamer from source on Windows is using MSYS2.

With DNS-SD

This feature is currently not available for Windows, but we're working on better solutions.

On Debian / Ubuntu, the following command will install the build dependencies:

apt install libavahi-compat-libdnssd-dev pkg-config

On the target system, install the runtime dependency:

apt install libavahi-compat-libdnssd1

If with-dns-sd is enabled, librespot will crash if Avahi or Bonjour is not running. On the other hand, if with-dns-sd was not enabled, librespot might interfere with Avahi, Bonjour or other librespot instances if running, or even crash on some OSs. A typical symptom is that Avahi detects a host name conflict, and then retries with '-2' appended to the host name, leading to 'hostname.local' not being resolved any longer.