Skip to content

Instantly share code, notes, and snippets.

@icyveins7
Last active September 28, 2021 06:33
Show Gist options
  • Save icyveins7/258c9f03c4e5eda54852306a24408e36 to your computer and use it in GitHub Desktop.
Save icyveins7/258c9f03c4e5eda54852306a24408e36 to your computer and use it in GitHub Desktop.
GNURadio Build-from-Source Quirks (With UHD)

Introduction

This guide is meant to serve as a source of stupid 'tricks' needed to get a GNURadio installation working when built from source, but not via PyBOMBS. For now, this guide will focus on Linux systems, as getting it working on Windows is a whole other nightmare.

Who should read this?

  1. You don't want to use PyBOMBS because you prefer to know what you're installing and where.
  2. You want to integrate the GNURadio libraries into an existing Python virtual environment, NOT the system-wide Python environment.
  3. You don't want to have to resort to using sudo when running things.

Caveats

In particular, I do not install all the modules. I have left out the following: gr-video-sdl, gr-zeromq, gr-soapy. However, I only extensively use gr-uhd, so bear in mind that some of the other modules may not work even though I built them.

Getting Ready

The basic link is here. However, we will not be following this exactly, in order to accomplish our goals of using an existing virtual environment. As such, do not install all the dependencies listed using apt. I used cmake-gui extensively as it made the process of finding new CMake build commands much easier, so you can sudo apt install cmake cmake-gui.

I assume that you already have a Python virtualenv set up, that you intend to use with the GNURadio installation. I call my environment main and I use virtualenvwrapper which uses virtualenv, so I'm not sure what would happen with venv style environments, but I don't think it's important. For reference, my virtual environment is stored in ~/.virtualenvs/main.

Tested Configuration/Versions

  1. GNURadio 3.9.2.0
  2. UHD 4.1.0.1
  3. Boost 1.77.0
  4. PyQt5 5.12.3 (pip)

Pre-requisite 1: Building Boost

While this is not necessary in theory, I built Boost myself and used it to build UHD myself, so I'll go through it here.

  1. Download the Boost source code from here. If you'd like to use a different version, I don't think there will be an issue as long as it satisfies the minimum requirements.
  2. Unzip, untar etc etc. My setup was ~/boost_1_77_0.
  3. Build the Boost library binaries via https://www.boost.org/doc/libs/1_77_0/more/getting_started/unix-variants.html.
  4. Be sure to specify a prefix; use a new folder in your home directory for now.
  5. After building, I like keeping things together so I moved the libraries into the Boost directory under /lib (there was already an existing ~/boost_1_77_0/libs directory).

Pre-requisite 2: Building UHD

We do the following installs with apt and pip (after activating your virtual environment) respectively:

sudo apt install libusb-1.0-0-dev
pip install mako numpy requests
  1. Download the source code from the Releases of the UHD USRP repository; I don't like cloning the repository directly as I'd have no idea what random nightly changes have been committed.
  2. Unzip, untar etc. This was ~/uhd-4.1.0.1 for me.
  3. Use cmake-gui to open the /host folder (source code) and to create the /build folder (where to build the binaries) inside the folder we just unzipped to.
  4. Run the first 'Configure'.
  5. Depending on what errors there are, fix them (hur hur obviously, see below).
  6. Choose a CMAKE_INSTALL_PREFIX to be somewhere that doesn't require root privileges (I just use ~/uhd-4.1.0.1-install).
  7. 'Generate' when done, then make -j4 (because I has cores) and make install.
  8. Add the following paths or your equivalents
export PATH=$PATH:/home/user/uhd-4.1.0.1-install/bin
export LD_LIBRARY_PATH:$LD_LIBRARY_PATH:/home/user/uhd-4.1.0.1-install/lib

Obvious UHD CMake Errors/Things to Check

  1. Set Boost_INCLUDE_DIR to where you unzipped Boost (my equivalent of ~/boost_1_77_0). Run Configure again and it should repopulate the other Boost fields and find Boost; 'Boost_DIR' was not needed for me. Note: you may see a lot of Boost warnings, but it should be okay. If it still doesn't work, you may need to add the built Boost libraries to your LD_LIBRARY_PATH (you would need to this later on anyway). Add a line like this to ~/.bashrc, pointing to the folder containing the built library binaries:
export LD_LIBRARY_PATH:$LD_LIBRARY_PATH:/home/username/boost_1_77_0/lib
  1. If you forgot to activate your virtual environment, do so and restart cmake-gui. Make sure 'Python3_EXECUTABLE' points to your virtual environment's interpreter, NOT the system one. It is okay for 'PYTHON_INCLUDE_DIR', 'PYTHON_LIBRARY' to point to the system ones in /usr/include and /usr/lib.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment