Skip to content

Compile in MacOS

srcejon edited this page Feb 18, 2024 · 20 revisions

Build for Mac using Macports

Prerequisites

Build and run

In a terminal, run:

sudo port selfupdate
port search sdrangel
sudo port install sdrangel
sdrangel

Build for Mac

Prerequisites

  • Install XCode from AppStore (If building on Mojave, use Xcode 11.3.1 from Apple developer website, rather than App Store)
  • Install Qt 5.15.2 or Qt 6.6.0 (if Arm) from https://www.qt.io/download (Installed in $HOME/Qt) (This includes cmake)
  • Install git from https://git-scm.com/download/mac if not included with XCode
  • Install svn (Subversion) if not installed as part of Xcode (From brew, macports or build from source see below)
  • Install SDRPlay API from SDRplay.com (For x64 SDRplay_RSP_API-MaxOSX-3.07.3.pkg - Installs headers in to /usr/local) - For ARM, use 3.12.1.)
  • Install Python 3 from https://www.python.org/downloads/ (If not already installed)
  • Install pip and other python packages:
    python3 -m pip install --upgrade pip 
    pip3 install numpy mako requests Cheetah3 setuptools
  • Create directories:
    sudo mkdir -p /opt/build
    sudo chown $USER:staff /opt/build
    sudo mkdir -p /opt/install
    sudo chown $USER:staff /opt/install
  • Compile Subversion if binary not available (E.g. on arm):
    cd /opt/build
    curl -L -Ok https://www.openssl.org/source/openssl-1.1.1w.tar.gz
    tar xf openssl-1.1.1w.tar.gz
    cd openssl-1.1.1w
    perl ./Configure --prefix=/opt/install/opensll --openssldir=/opt/install/opensll/openssl no-ssl3 no-ssl3-method darwin64-arm64-cc
    make 
    make install
    cd /opt/install
    curl -L -Ok http://downloads.sourceforge.net/project/scons/scons-local/4.5.2/scons-local-4.5.2.tar.gz
    mkdir scons-local-4.5.2
    cd scons-local-4.5.2
    tar xf ../scons-local-4.5.2.tar.gz
    cd /opt/build
    curl -Ok https://dlcdn.apache.org/subversion/subversion-1.14.2.tar.gz
    tar xf subversion-1.14.2.tar.gz
    cd subversion-1.14.2
    (Edit get-deps.sh and increase APR_VERSION to 1.7.4 and SERF_VERSION to 1.3.10 to build with arm)
    ./get-deps.sh   
    mkdir build-apr
    cd build-apr
    ../apr/configure --prefix=/opt/install/apr
    make all install
    cd ..
    mkdir build-apr-util
    cd build-apr-util
    ../apr-util/configure --prefix=/opt/install/apr --with-apr=/opt/install/apr
    make all install
    cd ../
    cd serf
    python3 /opt/install/scons-local-4.5.2/scons.py APR=/opt/install/apr APU=/opt/install/apr-util PREFIX=/opt/install/serf OPENSSL=/opt/install/openssl
    python3 /opt/install/scons-local-4.5.2/scons.py install
    cd ..
    mkdir build
    cd build
    ../configure --prefix=/opt/install/subversion-1.14.2 --with-apr=/opt/install/apr --with-apr-util=/opt/install/apr-util --with-serf=/opt/install/serf --with-lz4=internal --with-utf8proc=internal
    make all install
  • Install nasm (needed for FFMpeg on x86, not on arm)
    cd /opt/install
    curl -Ok https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/macosx/nasm-2.15.05-macosx.zip
    unzip nasm-2.15.05-macosx.zip
  • Compile pkg-config
    cd /opt/build
    curl -Ok https://pkg-config.freedesktop.org/releases/pkg-config-0.29.2.tar.gz
    tar xf pkg-config-0.29.2.tar.gz 
    cd pkg-config-0.29.2
    mkdir build
    cd build
    ../configure --prefix=/opt/install/pkg-config-0.29.2 --with-internal-glib
    make all install
  • Compile Soapy and SoapyRemote
    cd /opt/build
    git clone https://github.com/pothosware/SoapySDR.git
    cd SoapySDR
    mkdir build
    cd build
    cmake -DCMAKE_INSTALL_PREFIX=/opt/install/SoapySDR ..
    make all install
    cd /opt/build
    git clone https://github.com/pothosware/SoapyRemote.git
    cd SoapyRemote
    mkdir build
    cd build
    cmake -DCMAKE_INSTALL_PREFIX=/opt/install/SoapySDR -DSOAPY_SDR_INCLUDE_DIR=/opt/install/SoapySDR/include -DSOAPY_SDR_LIBRARY=/opt/install/SoapySDR/lib/libSoapySDR.dylib .. 
    make all install
  • On x86: Set up PATH environment variable:
    export QT_DIR=$HOME/Qt/
    export PATH=$QT_DIR/5.15.2/clang_64/bin:$PATH
    export PATH=$QT_DIR/Tools/CMake/CMake.app/Contents/bin:$PATH
    export PATH=/opt/install/subversion-1.14.2/bin:$PATH
    export PATH=/opt/install/pkg-config-0.29.2/bin:$PATH
    export PATH=/opt/install/nasm-2.15.05:$PATH
  • On arm: Set up PATH environment variable:
    export QT_DIR=$HOME/Qt/
    export PATH=$QT_DIR/6.6.0/macOS/bin:$PATH
    export PATH=$QT_DIR/Tools/CMake/CMake.app/Contents/bin:$PATH
    export PATH=/opt/install/subversion-1.14.2/bin:$PATH
    export PATH=/opt/install/pkg-config-0.29.2/bin:$PATH

Download and build SDRangel

cd /opt/build
git clone https://github.com/f4exb/sdrangel.git
cd sdrangel
#git submodule update --init --recursive
mkdir build
cd build
cmake -Wno-dev -DDEBUG_OUTPUT=ON -DENABLE_RTLSDR=ON -DENABLE_BLADERF=ON -DENABLE_AIRSPY=ON -DENABLE_AIRSPYHF=ON -DENABLE_FUNCUBE=ON -DENABLE_HACKRF=ON -DENABLE_IIO=ON -DENABLE_LIMESUITE=ON -DENABLE_MIRISDR=ON -DENABLE_PERSEUS=ON -DENABLE_SDRPLAY=ON -DENABLE_SOAPYSDR=ON -DSOAPYSDR_DIR=/opt/install/SoapySDR -DENABLE_XTRX=ON -DENABLE_USRP=ON -DENABLE_EXTERNAL_LIBRARIES=ON -DBUNDLE=ON -DRX_SAMPLE_24BIT=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/install/sdrangel -DPKG_CONFIG_USE_CMAKE_PREFIX_PATH=TRUE -DCMAKE_PREFIX_PATH="$QT_DIR/5.15.2/clang_64" ..
make package

On Arm, use the make options:

-DENABLE_QT6=ON -DPYTHON_EXECUTABLE=/usr/bin/python3 -DCMAKE_PREFIX_PATH="$QT_DIR/6.6.0/macOS"

-DBUNDLE=ON is the option to create a .dmg

If there are SSL certificate errors fetching third party code, use -DCMAKE_TLS_VERIFY=FALSE

If you have multiple versions of Python installed, you can specify which has the required packages with -DPYTHON_EXECUTABLE=/Library/Frameworks/Python.framework/Versions/3.8/bin/python3

Use -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON to get make to display commands it is executing.

When building a x64 release, use -DARCH_OPT=nehalem so that AVX instructions aren't used, as some older CPUs do not have them (Will require SSE4_2).

Clone this wiki locally