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.
- You don't want to use PyBOMBS because you prefer to know what you're installing and where.
- You want to integrate the GNURadio libraries into an existing Python virtual environment, NOT the system-wide Python environment.
- You don't want to have to resort to using sudo when running things.
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.
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
.
- GNURadio 3.9.2.0
- UHD 4.1.0.1
- Boost 1.77.0
- PyQt5 5.12.3 (pip)
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.
- 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.
- Unzip, untar etc etc. My setup was ~/boost_1_77_0.
- Build the Boost library binaries via https://www.boost.org/doc/libs/1_77_0/more/getting_started/unix-variants.html.
- Be sure to specify a prefix; use a new folder in your home directory for now.
- 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).
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
- 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.
- Unzip, untar etc. This was ~/uhd-4.1.0.1 for me.
- 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.
- Run the first 'Configure'.
- Depending on what errors there are, fix them (hur hur obviously, see below).
- Choose a CMAKE_INSTALL_PREFIX to be somewhere that doesn't require root privileges (I just use ~/uhd-4.1.0.1-install).
- 'Generate' when done, then
make -j4
(because I has cores) andmake install
. - 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
- 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
- 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.