Compile macOS using macports

From Strawberry Music Player Wiki
Jump to navigation Jump to search

Compiling on macOS using macports.

Install xcode tools

   xcode-select --install

Install macports

Download and install macports from: https://www.macports.org/install.php

Prepare macports

   sudo port -v selfupdate

Install dependencies

   sudo port -N install glib2 pkgconfig cmake boost protobuf-cpp sqlite3 gnutls chromaprint fftw taglib
   sudo port -N install qt6-qtbase qt6-sqlite-plugin
   sudo port -N install qt6-qttools
   sudo port -N install gstreamer1 gstreamer1-gst-plugins-base gstreamer1-gst-plugins-good gstreamer1-gst-plugins-ugly gstreamer1-gst-libav
   sudo port -N install gstreamer1-gst-plugins-bad +faac +fdk_aac
   sudo port -N install libcdio libmtp
   sudo port -N install libgpod

Install create-dmg

   mkdir -p ~/build
   cd ~/build
   git clone https://github.com/create-dmg/create-dmg
   cd create-dmg
   sudo make install

Set environment variables

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

Prepare build

   mkdir -p ~/build
   cd ~/build
   git clone https://github.com/strawberrymusicplayer/strawberry
   cd strawberry
   mkdir build
   cd build

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

Compile and create DMG

   cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=/opt/local/lib/cmake -DBUILD_WITH_QT6=ON -DUSE_BUNDLE=ON
   make -j$(nproc)
   make install
   install_name_tool -change "@rpath/QtCore.framework/Versions/A/QtCore" "/opt/local/libexec/qt6/lib/QtCore.Framework/Versions/A/QtCore" 3rdparty/macdeployqt/macdeployqt
   install_name_tool -change "@rpath/QtCore.framework/Versions/A/QtCore" "/opt/local/libexec/qt6/lib/QtCore.Framework/Versions/A/QtCore" ext/macdeploycheck/macdeploycheck
   make deploy
   make dmg

You might get warnings in make deploy about missing gstreamer plugins because macports does not have all of them, they are not critical and Strawberry should still work.

Install

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