Skip to content

Compile from source in Linux

Edouard Griffiths edited this page Jul 24, 2023 · 126 revisions

Instructions

Compiling from source can be done by building a Docker image with the SDRangel in Docker project more specifically the SDRangel section. Note that you may also execute the instructions in the Dockerfile manually although building with Docker will do the same automatically.

If you choose to compile from source it is assumed that the machine on which you compile is also the machine on which you run SDRangel.

Instructions for manual build

Compiling from source is assumed to be done in a Linux system with an Ubuntu 22.04 distribution (thus Qt 5.15).

The minimal standard required for the C++ compiler is c++14

Be aware that it will try to apply the highest SIMD capabilities available on your CPU i.e. AVX2 > AVX > SSE4 ... So for best results make sure you run the program on the computer on which you compile or you are using the compiled binaries on a computer with similar SIMD capabilities (check the CPU flags with cat /proc/cpuinfo). The typical issue encountered when running hardware is not compatible is a SIGILL exception with a message like Program received signal SIGILL, Illegal instruction.

It assumes /opt/build is the base for the sources used to build and /opt/install is the base for the installation directories. It is assumed these directories are owned by your user. Hence assuming the user is $USER in group users you would do the following to create them (once):

sudo mkdir -p /opt/build
sudo chown $USER:users /opt/build
sudo mkdir -p /opt/install
sudo chown $USER:users /opt/install

You may change these locations at your will like using your home directory for the sources but it is strongly advised not to use the system directories for installation (/usr, /usr/local) and thus never have to do sudo make install. This is a bad idea as a principle for application software.

As a general prerequisite you should have the following packages installed:

sudo apt-get update && sudo apt-get -y install \
git cmake g++ pkg-config autoconf automake libtool libfftw3-dev libusb-1.0-0-dev libusb-dev libhidapi-dev libopengl-dev \
qtbase5-dev qtchooser libqt5multimedia5-plugins qtmultimedia5-dev libqt5websockets5-dev \
qttools5-dev qttools5-dev-tools libqt5opengl5-dev libqt5quick5 libqt5charts5-dev \
qml-module-qtlocation  qml-module-qtpositioning qml-module-qtquick-window2 \
qml-module-qtquick-dialogs qml-module-qtquick-controls qml-module-qtquick-controls2 qml-module-qtquick-layouts \
libqt5serialport5-dev qtdeclarative5-dev qtpositioning5-dev qtlocation5-dev libqt5texttospeech5-dev \
qtwebengine5-dev qtbase5-private-dev libqt5gamepad5-dev \
libfaad-dev zlib1g-dev libboost-all-dev libasound2-dev pulseaudio libopencv-dev libxml2-dev bison flex \
ffmpeg libavcodec-dev libavformat-dev libopus-dev doxygen graphviz

Non-hardware dependencies

These are dependencies, and are required to build SDRangel properly with all its plugins. Since not all of these are distributed in upstream packages (or don't have the tested version upstream), it is required that these are also build from source.

APT

# Optionally: sudo apt-get install libsndfile-dev
cd /opt/build
git clone https://github.com/srcejon/aptdec.git
cd aptdec
git checkout libaptdec
git submodule update --init --recursive
mkdir build; cd build
cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/aptdec ..
make -j $(nproc) install

CM265cc

cd /opt/build
git clone https://github.com/f4exb/cm256cc.git
cd cm256cc
git reset --hard c0e92b92aca3d1d36c990b642b937c64d363c559
mkdir build; cd build
cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/cm256cc ..
make -j $(nproc) install

LibDAB

cd /opt/build
git clone https://github.com/srcejon/dab-cmdline
cd dab-cmdline/library
git checkout msvc
mkdir build; cd build
cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/libdab ..
make -j $(nproc) install

MBElib

cd /opt/build
git clone https://github.com/szechyjs/mbelib.git
cd mbelib
git reset --hard 9a04ed5c78176a9965f3d43f7aa1b1f5330e771f
mkdir build; cd build
cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/mbelib ..
make -j $(nproc) install

SerialDV

cd /opt/build
git clone https://github.com/f4exb/serialDV.git
cd serialDV
git reset --hard "v1.1.4"
mkdir build; cd build
cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/serialdv ..
make -j $(nproc) install

DSDcc

cd /opt/build
git clone https://github.com/f4exb/dsdcc.git
cd dsdcc
git reset --hard "v1.9.3"
mkdir build; cd build
cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/dsdcc -DUSE_MBELIB=ON -DLIBMBE_INCLUDE_DIR=/opt/install/mbelib/include -DLIBMBE_LIBRARY=/opt/install/mbelib/lib/libmbe.so -DLIBSERIALDV_INCLUDE_DIR=/opt/install/serialdv/include/serialdv -DLIBSERIALDV_LIBRARY=/opt/install/serialdv/lib/libserialdv.so ..
make -j $(nproc) install

Codec2/FreeDV

sudo apt-get -y install libspeexdsp-dev libsamplerate0-dev
cd /opt/build
git clone https://github.com/drowe67/codec2.git
cd codec2
mkdir build_linux; cd build_linux
cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/codec2 ..
make -j $(nproc) install

SGP4

cd /opt/build
git clone https://github.com/dnwrnr/sgp4.git
cd sgp4
mkdir build; cd build
cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/sgp4 ..
make -j $(nproc) install

LibSigMF

cd /opt/build
git clone https://github.com/f4exb/libsigmf.git
cd libsigmf
git checkout "new-namespaces"
mkdir build; cd build
cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/libsigmf .. 
make -j $(nproc) install

Hardware dependencies

You can choose to compile only the plugins corresponding to your hardware. In the final step to build SDRangel specify only the directories that correspond to your hardware.

For those installations instructions that include something similar to: -DINSTALL_UDEV_RULE=OFF this will not install the udev rules (since you aren't running as root), but this may cause the hardware not to function if this is the first time you are installing that specific library. You can find how to install the udev rules in the Quick start

Specific versions of packages listed are the ones developers have tested, and are known to work. If you use more up to date versions you are basically on your own.

Airspy

cd /opt/build
git clone https://github.com/airspy/airspyone_host.git libairspy
cd libairspy
git reset --hard 37c768ce9997b32e7328eb48972a7fda0a1f8554
mkdir build; cd build
cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/libairspy ..
make -j $(nproc) install

SDRplay RSP1

cd /opt/build
git clone https://github.com/f4exb/libmirisdr-4.git
cd libmirisdr-4
mkdir build; cd build
cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/libmirisdr ..
make -j $(nproc) install

SDRplay (Using SDRplay's V3 API)

Either download the API from: [SDRplay](https://www.sdrplay.com/downloads/) or run:
git clone https://github.com/srcejon/sdrplayapi.git
cd sdrplayapi
sudo ./install_lib.sh

RTL-SDR

cd /opt/build
git clone https://github.com/osmocom/rtl-sdr.git librtlsdr
cd librtlsdr
git reset --hard be1d1206bfb6e6c41f7d91b20b77e20f929fa6a7
mkdir build; cd build
cmake -Wno-dev -DDETACH_KERNEL_DRIVER=ON -DCMAKE_INSTALL_PREFIX=/opt/install/librtlsdr ..
make -j $(nproc) install

Pluto SDR

cd /opt/build
git clone https://github.com/analogdevicesinc/libiio.git
cd libiio
git reset --hard v0.21
mkdir build; cd build
cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/libiio -DINSTALL_UDEV_RULE=OFF ..
make -j $(nproc) install

You will need firmware 0.29 or above.

BladeRF all versions

cd /opt/build
git clone https://github.com/Nuand/bladeRF.git
cd bladeRF/host
git reset --hard "2023.02"
mkdir build; cd build
cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/libbladeRF -DINSTALL_UDEV_RULES=OFF ..
make -j $(nproc) install

HackRF

cd /opt/build
git clone https://github.com/greatscottgadgets/hackrf.git
cd hackrf/host
git reset --hard "v2022.09.1"
mkdir build; cd build
cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/libhackrf -DINSTALL_UDEV_RULES=OFF ..
make -j $(nproc) install

LimeSDR

cd /opt/build
git clone https://github.com/myriadrf/LimeSuite.git
cd LimeSuite
git reset --hard "v20.01.0"
mkdir builddir; cd builddir
cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/LimeSuite ..
make -j $(nproc) install

AirspyHF

cd /opt/build
git clone https://github.com/airspy/airspyhf
cd airspyhf
git reset --hard 1af81c0ca18944b8c9897c3c98dc0a991815b686
mkdir build; cd build
cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/libairspyhf ..
make -j $(nproc) install

Perseus

cd /opt/build
git clone https://github.com/f4exb/libperseus-sdr.git
cd libperseus-sdr
git checkout fixes
git reset --hard afefa23e3140ac79d845acb68cf0beeb86d09028
mkdir build; cd build
cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/libperseus ..
make -j $(nproc)
make install

USRP

Prerequisites:

sudo apt install libboost-all-dev libusb-1.0-0-dev python3-mako doxygen python3-docutils cmake build-essential
cd /opt/build
git clone https://github.com/EttusResearch/uhd.git
git reset --hard v4.3.0.0
cd uhd/host
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/install/uhd ../
make -j $(nproc)
make install
/opt/install/uhd/lib/uhd/utils/uhd_images_downloader.py
# The following aren't required if installed to /
echo /opt/install/uhd/lib | sudo dd of=/etc/ld.so.conf.d/uhd.conf
sudo ldconfig
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/opt/install/uhd/lib/pkgconfig
# Enable USB access from user accounts
cd /opt/install/uhd/lib/uhd/utils
sudo cp uhd-usrp.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules
sudo udevadm trigger

XTRX

Prerequisites:

sudo apt-get -y install build-essential libusb-1.0-0-dev cmake dkms python python3-cheetah

Prerequisites 18.04:

sudo apt-get -y install build-essential libusb-1.0-0-dev cmake dkms python3 python3-pip
sudo pip3 install Cheetah3
cd /opt/build
git clone https://github.com/f4exb/images.git xtrx-images
cd xtrx-images
git submodule init
git submodule update
cd sources
mkdir build; cd build
cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/xtrx-images -DENABLE_SOAPY=NO ..
make -j $(nproc)
make install

To use XTRX because libxtrx has dependent sub-libraries before starting SDRangel you need to add the library path to LD_LIBRAY_PATH with export LD_LIBRARY_PATH=/opt/install/xtrx-images/lib:$LD_LIBARY_PATH. If you start SDRangel in a shell script you have to add the export before invoking SDRangel.

Soapy SDR

SoapySDR is a bit special since it is an interface with the libraries that interface the hardware so there is a kind of double indirection. We will detail an installation that is done completely outside the standard paths as it has been done done until now. Thus we will refrain from the easy but risky sudo make install.

First let's compile the main SoapySDR stuff:

cd /opt/build
git clone https://github.com/pothosware/SoapySDR.git
cd SoapySDR
git reset --hard "soapy-sdr-0.7.1"
mkdir build; cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/install/SoapySDR ..
make -j $(nproc) install

So far so good but we will need the support libraries that are the pieces (plugins) that make the link between SoapySDR and the libraries that drive the hardware. They have to be compiled one by one separately as you need them. Let's take a simple example for RTL-SDR assuming that librtlsdr has been compiled and installed as described earlier in /opt/install/librtlsdr:

RTL-SDR

cd /opt/build
git clone https://github.com/pothosware/SoapyRTLSDR.git
cd SoapyRTLSDR
mkdir build; cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/install/SoapySDR  -DRTLSDR_INCLUDE_DIR=/opt/install/librtlsdr/include -DRTLSDR_LIBRARY=/opt/install/librtlsdr/lib/librtlsdr.so -DSOAPY_SDR_INCLUDE_DIR=/opt/install/SoapySDR/include -DSOAPY_SDR_LIBRARY=/opt/install/SoapySDR/lib/libSoapySDR.so ..
make -j $(nproc) install

The support libraries are installed in /opt/install/SoapySDR/lib/SoapySDR/modules0.7 (for the 0.7 version).

HackRF

cd /opt/build
git clone https://github.com/pothosware/SoapyHackRF.git
cd SoapyHackRF
mkdir build; cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/install/SoapySDR -DLIBHACKRF_INCLUDE_DIR=/opt/install/libhackrf/include/libhackrf -DLIBHACKRF_LIBRARY=/opt/install/libhackrf/lib/libhackrf.so -DSOAPY_SDR_INCLUDE_DIR=/opt/install/SoapySDR/include -DSOAPY_SDR_LIBRARY=/opt/install/SoapySDR/lib/libSoapySDR.so ..
make -j $(nproc) install

LimeSDR

Assuming you already have cloned LimeSuite and build it in the corresponding previous step.

cd /opt/build
cd LimeSuite/builddir
cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/LimeSuite -DCMAKE_PREFIX_PATH=/opt/install/SoapySDR ..
make -j $(nproc) install
cp /opt/install/LimeSuite/lib/SoapySDR/modules0.7/libLMS7Support.so /opt/install/SoapySDR/lib/SoapySDR/modules0.7

Soapy Remote

sudo apt-get -y install libavahi-client-dev
cd /opt/build
git clone https://github.com/pothosware/SoapyRemote.git
cd SoapyRemote
git reset --hard "soapy-remote-0.5.1"
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.so ..
make -j $(nproc) install

Build SDRangel

  • This is for a 24 bit samples build. For 16 bit use -DRX_SAMPLE_24BIT=OFF

Additional options on cmake line for partial compilation:

  • -DBUILD_SERVER=OFF to compile the GUI variant only
  • -DBUILD_GUI=OFF to compile the server variant only

Commands are:

cd /opt/build
git clone https://github.com/f4exb/sdrangel.git
cd sdrangel
mkdir build; cd build
cmake -Wno-dev -DDEBUG_OUTPUT=ON -DRX_SAMPLE_24BIT=ON \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DMIRISDR_DIR=/opt/install/libmirisdr \
-DAIRSPY_DIR=/opt/install/libairspy \
-DAIRSPYHF_DIR=/opt/install/libairspyhf \
-DBLADERF_DIR=/opt/install/libbladeRF \
-DHACKRF_DIR=/opt/install/libhackrf \
-DRTLSDR_DIR=/opt/install/librtlsdr \
-DLIMESUITE_DIR=/opt/install/LimeSuite \
-DIIO_DIR=/opt/install/libiio \
-DPERSEUS_DIR=/opt/install/libperseus \
-DXTRX_DIR=/opt/install/xtrx-images \
-DSOAPYSDR_DIR=/opt/install/SoapySDR \
-DUHD_DIR=/opt/install/uhd \
-DAPT_DIR=/opt/install/aptdec \
-DCM256CC_DIR=/opt/install/cm256cc \
-DDSDCC_DIR=/opt/install/dsdcc \
-DSERIALDV_DIR=/opt/install/serialdv \
-DMBE_DIR=/opt/install/mbelib \
-DCODEC2_DIR=/opt/install/codec2 \
-DSGP4_DIR=/opt/install/sgp4 \
-DLIBSIGMF_DIR=/opt/install/libsigmf \
-DDAB_DIR=/opt/install/libdab \
-DCMAKE_INSTALL_PREFIX=/opt/install/sdrangel ..
make -j $(nproc) install

Build for Qt6

Since version 7.8.4 the code is compatible with Qt6 but is still experimental. First you have to install Qt6 dependencies:

sudo apt-get update && sudo apt-get -y install \
    qt6-base-dev \
    libqt6websockets6-dev \
    qt6-multimedia-dev \
    libqt6serialport6-dev \
    libqt6core5compat6-dev \
    libqt6multimedia6 \
    libqt6opengl6-dev \
    libqt6quick6 \
    libqt6charts6-dev \
    qml6-module-qtpositioning \
    qml6-module-qtquick-window \ 
    qml6-module-qtquick-dialogs \
    qml6-module-qtquick-controls \
    qml6-module-qtquick-layouts \
    libqt6serialport6-dev \
    qt6-declarative-dev \
    qt6-webengine-dev \
    qt6-base-private-dev    
    qt6-webengine-dev-tools

Then you can use the cmake Qt6 preset:

cd /opt/build/sdrangel
cmake --preset default-qt6
cd build-qt6
make -j $(nproc) install

Developer Docs

There is always a balance between spending time working on developer documentation and a focus on getting functional software. SDRAngel developers (like most developers) give working software a higher priority than comprehensive documentation. End user documentation is found on this wiki. Developer documentation is created on your machine. To do this, ensure that these additional packages are installed before the additional cmake step above.

sudo apt-get update && sudo apt-get -y install doxygen graphviz 

then during the cmake, you should see an additional message:

-- added optional 'make dev_docs' for developer documentation generation

now you have an additional make target, make dev_docs; which will take 5-10 minutes and build up developer docs; to allow you better understand the SDRangel codebase. From here you can examine classes, files, and source.

For those interested in adding new devices, start with (search for):

  • DeviceSampleSink & DeviceSampleSource classes

For those interested in adding new modulators or demodulators, start with (search for):

  • BasebandSampleSink and BasebandSampleSource classes

For those interested in helping with additional documentation, check out the dox.warn file in the build directory for various symbols, parameters and arguments, which need documentation. This would be a good way for anyone to get familiar with the code base before actually contributing code changes.

These docs will end up in your build directory, and can be viewed with your favorite browser:

firefox ./dev_docs/index.html

Run SDRangel

For the GUI variant in a terminal do /opt/install/sdrangel/bin/sdrangel

For the server variant the best is to use Docker particularly in the armv8 architecture. It is also possible to use supervisor see the Wiki pages "SDRangel server with supervisor...".

Clone this wiki locally