Compile macOS using homebrew

From Strawberry Music Player Wiki
Jump to navigation Jump to search

Compile on macOS using homebrew

Install xcode tools and brew package manager

   xcode-select --install
   /usr/bin/ruby -e "$(curl -fsSL"

Install dependencies through brew

   brew install pkg-config cmake ninja meson bison flex wget create-dmg gettext boost protobuf protobuf-c ccache
   brew install glib glib-openssl glib-utils glib-networking gdk-pixbuf gobject-introspection orc
   brew install libffi openssl gnutls sqlite fftw libmtp libplist libsoup libxml2
   brew install libogg libvorbis flac wavpack opus speex mpg123 lame twolame taglib chromaprint libbs2b libcdio libopenmpt faad2 faac fdk-aac musepack game-music-emu
   brew install qt6

Homebrew is missing several gstreamer plugins, so we build gstreamer from source.

   mv gstreamer.rb gst-plugins-{base,good,bad,ugly}.rb gst-libav.rb /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/
   brew install --build-from-source gstreamer
   brew install --build-from-source gst-plugins-base
   brew install --build-from-source gst-plugins-good
   brew install --build-from-source gst-plugins-bad
   brew install --build-from-source gst-plugins-ugly
   brew install --build-from-source gst-libav

Set environment variables

for Intel x86_64:

   export GIO_EXTRA_MODULES=/usr/local/lib/gio/modules
   export GST_PLUGIN_SCANNER=/usr/local/opt/gstreamer/libexec/gstreamer-1.0/gst-plugin-scanner
   export GST_PLUGIN_PATH=/usr/local/lib/gstreamer-1.0

for Apple Silicon:

   export GIO_EXTRA_MODULES=/opt/homebrew/lib/gio/modules
   export GST_PLUGIN_SCANNER=/opt/homebrew/opt/gstreamer/libexec/gstreamer-1.0/gst-plugin-scanner
   export GST_PLUGIN_PATH=/opt/homebrew/lib/gstreamer-1.0

Prepare build

   mkdir -p ~/build
   cd ~/build
   git clone
   cd strawberry
   mkdir build
   cd build

(If you already did `git clone`, do `git pull` to make sure you have the latest code).

Configure build

for Intel x86_64:

   cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/usr/local/opt/qt6/lib/cmake -DBUILD_WITH_QT6=ON -DUSE_BUNDLE=ON -DENABLE_SPARKLE=OFF -DICU_ROOT=/usr/local/opt/icu4c

for Apple Silicon:

   cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/opt/homebrew/opt/qt6/lib/cmake -DBUILD_WITH_QT6=ON -DUSE_BUNDLE=ON -DENABLE_SPARKLE=OFF -DICU_ROOT=/usr/local/opt/icu4c


   make -j$(nproc)
   make install

Remove problematic unneeded plugins

   sudo rm -rf /usr/local/opt/qt6/share/qt/plugins/virtualkeyboard /usr/local/opt/qt6/share/qt/plugins/platforminputcontexts
   sudo rm -f /usr/local/Cellar/qt/*/share/qt/plugins/imageformats/libqpdf.dylib

Manually copy files

You need to manually copy libsoup-3.0.0.dylib, as this library needs to be loaded by gstreamer at runtime:

   mkdir -p
   cp /usr/local/lib/libsoup-3.0.0.dylib


   make deploy

Create DMG

   make dmg


To install, either open the DMG, drag Strawberry over to Applications, or manually copy the folder over to /Applications/