-Source 버전 용이
-Ubuntu는 동일 os라도 문제 생기기도 함
-gr 3.7, 3.8 가장 많이 사용하고 Ubuntu 20.04 사용 추천
Building and installing UHD from source code
Development Environment:
Ubuntu20.04 LTS
Update and Install dependencies
(1) Update
sudo apt-get update
(2)
sudo apt install git cmake g++ libboost-all-dev libgmp-dev swig python3-numpy \
python3-mako python3-sphinx python3-lxml doxygen libfftw3-dev \
libsdl1.2-dev libgsl-dev libqwt-qt5-dev libqt5opengl5-dev python3-pyqt5 \
liblog4cpp5-dev libzmq3-dev python3-yaml python3-click python3-click-plugins \
python3-zmq python3-scipy python3-gi python3-gi-cairo gir1.2-gtk-3.0 \
libcodec2-dev libgsm1-dev libusb-1.0-0 libusb-1.0-0-dev libudev-dev
Chose GNU Radio version 3.8.x with Python 3 support (Ubuntu 20.04 LTS supports Python3.8)
Reference: https://wiki.gnuradio.org/index.php?title=Draft-AN-445#Building_and_installing_UHD_from_source_code
Building and installing UHD from source code
(1) Navigate to Home Directory
cd $HOME/
Open a terminal and navigate to your home directory
(2) Clone the UHD Repository into your home directory
git clone https://github.com/EttusResearch/uhd.git
cd $HOME/uhd
Clone the UHD source code into your home directory and navigate into it
(3) Switch to a Specific Branch
git checkout v3.15.0.0
Switch to the desired branch for a specific version of UHD (e.g., version 3.15.0.0)
(4) Prepare Build Directory
cd host
mkdir build
cd build
Navigate to the host directory inside uhd, create a build directory
(5) Configure Installation Path
cmake -DCMAKE_INSTALL_PREFIX=/usr/local ../
Run cmake to configure the build system, setting the installation prefix to /usr/local (or the prefix where GNU Radio is installed)
(6) Build and Install
(make -j3 will use 3 threads in the build)
make -j3
make test
sudo make install
sudo ldconfig
(Specify at most one less than the number of CPU cores so the system does not appear to ‘freeze’ during the build
If not specified, then a single thread is used for the build)
-Compile the UHD library using make
Adjust the -j option based on your CPU cores (using at most one less than the total number of cores to prevent the system from freezing)
-Run tests to verify the build
-Install UHD to the specified prefix and update the system’s library cache
(7) Configure Environment Variables
To ensure your system recognizes the installed libraries, add the UHD library path to your LD_LIBRARY_PATH environment variable
nano ~/.bashrc
Open ~/.bashrc with nano or your preferred text editor
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
Add the following line at the end of the file
Save and close the file. Apply the changes by sourcing ~/.bashrc or reopening your terminal
Reference: https://wiki.gnuradio.org/index.php?title=Draft-AN-445#Building_and_installing_UHD_from_source_code
Linux Install From Source
From Source
For GNU Radio 3.8 or Earlier
Installing GNU Radio
(1) Navigate to the Home Directory and Clone the Repository
cd
git clone https://github.com/gnuradio/gnuradio.git
cd gnuradio
Change to your home directory and clone the GNU Radio repository
(2) Selecting the Version to Install
git checkout maint-3.8
git submodule update --init --recursive
mkdir build
cd build
(If you prefer to install version 3.7, replace maint-3.8 with maint-3.7 in the command above)
-Update submodules and prepare the build directory
(3) Configuring the Build
Configure Installation Options
cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=/usr/bin/python3 ../
make -j3 (e.g. if you want to use 3 CPU cores during the build. To use 8 do -j8, to use all cores use -j$(nproc), to use 1 leave out the -j flag.)
-Specify the installation prefix (where GNU Radio will be installed) if you don’t want the default /usr/local. Replace XXX with your desired installation path
-To build, decide how many CPU cores you’d like to use
For 3 cores, use make -j3
-To use all available cores
Replace 3 with $(nproc)
(4) Building and Testing
make test
sudo make install
Build, Test, and Install
-Compile GNU Radio, Run tests(it’s normal for some tests to fail due to missing optional dependencies), and Install GNU Radio
Error:
The following tests FAILED:
25 - qa_volk_32f_8u_polarbutterflypuppet_32f (Failed)
Can be ignored..
Ref: https://github.com/gnuradio/volk/issues/340
(5) Finalizing the Installation
sudo ldconfig
Update the System’s Library Cache: Important to refresh the system’s library paths after installation
ModuleNotFoundError
(1) Identifying the GNU Radio Installation Prefix
To resolve a ModuleNotFoundError, you first need to find out where GNU Radio is installed on your system
This information is necessary for ensuring that your environment is correctly set up to find GNU Radio modules
gnuradio-config-info --prefix
Once you have the GNU Radio installation prefix, you’ll use this path in place of {your-prefix} in any subsequent commands that require specifying the installation location of GNU Radio
(2) Finding the Python library
Using a terminal, enter the following command, substituting the prefix you found above in place of {your-prefix}:
find {your-prefix} -name gnuradio | grep "packages"
#ME
find /usr/local -name gnuradio | grep "packages"
Find the Python library paths associated with GNU Radio. These paths are necessary to ensure that your Python environment can correctly locate and import GNU Radio modules
Put the appropriate paths it found into the export commands below. Note that the paths are separated by colons :
In the terminal, execute the following command. Remember to replace {your-prefix} with the actual installation prefix you discovered previously
(3) Setting PYTHONPATH
export PYTHONPATH={your-prefix}/lib/{Py-version}/dist-packages:{your-prefix}/lib/{Py-version}/site-packages:$PYTHONPATH
#ME
export PYTHONPATH=/usr/local/lib/python3/dist-packages:/usr/local/lib/python3.8/site-packages:$PYTHONPATH
-Use the following template to set your PYTHONPATH, replacing {your-prefix} with your GNU Radio installation prefix and {Py-version} with your Python version (e.g., python3.8)
-On Debian, Ubuntu, and similar systems, as well as on most 32-bit Unix/Linux systems, the paths typically follow this structure
(4) Setting LD_LIBRARY_PATH (Optional)
export LD_LIBRARY_PATH={your-prefix}/lib:$LD_LIBRARY_PATH
Ensure that the system’s dynamic linker/loader can find the GNU Radio libraries
(5) Store the commands in a Bash start-up file
nano ~/.bashrc
-Add the Export Commands
At the end of the file, paste the export commands you constructed for PYTHONPATH and LD_LIBRARY_PATH
-Save and Close the Editor
After adding the lines, save the changes and close the editor
Press Ctrl + O, Enter, and then Ctrl + X
(6) Applying the Changes
source ~/.bashrc
Source your .bashrc file
(7) Open gnuradio
gnuradio-companion
Reference: https://wiki.gnuradio.org/index.php?title=ModuleNotFoundError#B._Finding_the_Python_library
Use osmocom Gnu Radio Blocks
By using the OsmoSDR block you can take advantage of a common software api in your application(s) independent of the underlying radio hardware
Setting Up the Build Environment
(1) Clone the gr-osmosdr Repository
git clone https://git.osmocom.org/sdr/gr-osmosdr.git
cd gr-osmosdr/
=> Updated
git clone https://gitea.osmocom.org/sdr/gr-osmosdr
cd gr-osmosdr/
Building with cmake
(2) Switch to the Relevant Branch
git checkout gr3.8
(3) Preparing the Build
Initialize the Build Directory
mkdir build
cd build/
cmake ../
(4) Customizing the Build
Review Component Status
After running cmake, it will summarize which components are enabled or disabled. This step is crucial for ensuring that the specific functionalities you need are available. If a desired component is listed as disabled, it usually indicates missing dependencies
Now cmake should print out a summary of enabled/disabled components
You may disable certain components by following guidelines shown by cmake
Make sure the device of your interest is listed here. Check your dependencies and retry otherwise
(5) Install Missing Dependencies
sudo apt install libsoapysdr
Install any additional packages that are required.
For example, if libsoapysdr was listed as a missing dependency, you can install it and its development headers with
Enter libsoapysdr package installation > Enter tab
Confirm that the package exists
(6) Install extra packages that were listed as disabled
sudo apt install libsoapysdr-dev
(7) Verifying the Configuration
cd ~/gr-osmosdr/build/
cmake ../
Reconfigure to Check Changes
After installing the missing dependencies, return to your gr-osmosdr build directory and rerun cmake to update the configuration
This step will verify if the previously disabled components are now enabled, thanks to the installed dependencies
(8) Build & Install
make
sudo make install
sudo ldconfig
Reference: https://osmocom.org/projects/gr-osmosdr/wiki