Difference between revisions of "Building and Installing the USRP Open-Source Toolchain (UHD and GNU Radio) on OS X"

From Ettus Knowledge Base
Jump to: navigation, search
(Abstract)
(Update for macOS 11 Big Sur & recent developments on older MacOS)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Application Note Number==
+
==Application Note Number and Author==
'''AN-788'''
+
'''AN-788''' by Michael Dickens
 
+
<!-- Internal use only: please do keep this updated!
 
==Revision History==
 
==Revision History==
 
{| class="wikitable"
 
{| class="wikitable"
Line 8: Line 8:
 
!Details
 
!Details
 
|-
 
|-
|style="text-algin:center;"| 2016-05-01  
+
|style="text-align:center;"| 2016-05-01
|style="text-algin:center;"| Michael Dickens  
+
|style="text-align:center;"| Michael Dickens
|style="text-algin:center;"| Initial creation
+
|style="text-align:center;"| Initial creation
 +
|-
 +
|style="text-align:center;"| 2020-02-07
 +
|style="text-align:center;"| Michael Dickens
 +
|style="text-align:center;"| OSX updates since creation
 +
|-
 +
|style="text-align:center;"| 2021-02-15
 +
|style="text-align:center;"| Michael Dickens
 +
|style="text-align:center;"| OSX updates
 +
 
 
|}
 
|}
 +
-->
  
 
==Abstract==
 
==Abstract==
This AN provides a comprehensive step-by-step guide for building, installing, and maintaining the open-source toolchain, specifically UHD and GNU Radio, for the USRP from source code on the Mac OS X platform.
 
  
==UHD on OS X==
+
This AN provides a comprehensive step-by-step guide for installing UHD (and GNU Radio) on ''OSX'' (Mac OS X / MacOS X 10.4 to 10.15) and ''macOS 11 or newer'' -- whether via a package manager or from source.
  
UHD has been compiled and installed on Mac OS X 10.6 ("Snow Leopard") through OSX 10.10 ("Yosemite") running any compatible version of Xcode on all recent and many older Macs. Primary support is for 64-bit Intel-based Macs, running 10.6 or newer. There is very little support for getting the background libraries and applications installed on Mac OS X 10.5 or earlier, for 32-bit installs, or for PowerPC based Macs, though any or all of these might be possible.
+
==UHD on OSX / macOS==
  
 +
UHD 3.9, 3.15, and 4.0 have been compiled and installed on OSX 10.4 ("Tiger") and 10.5 ("Leopard") for PowerPC or Intel 32-bit, OSX 10.6 ("Snow Leopard") through the OSX 10.15 ("Catalina") for Intel 64-bit, as well as macOS 11 ("Big Sur") Intel or ARM 64-bit running any compatible version of Xcode on all recent and many older Macs. In general UHD performance varies greatly depending on the computer's OS, CPU, and networking stack and hardware for ethernet and USB. For Macs there is more consistency between hardware and OS versions because of Apple's tight coupling of hardware and software; hence the broad OSX and hardware support for UHD.
 +
 +
Primary support is for 64-bit Intel-based Macs, running OSX 10.9 or newer using Clang / libc++; secondary support is for OSX 10.6 through 10.8 64-bit Intel-based Macs using Xcode's default GCC / libstdc++ or specially-installed Clang / libc++ (e.g., via MacPorts); tertiary support is for OSX 10.4 and 10.5 Intel or PowerPC 32-bit using Xcode's default GCC / libstdc++ (as of early 2021, Clang does not yet build reliably for these older OSX). There is very little support for getting the background libraries and applications installed on OSX 10.4 or 10.5 (in general, and for 64-bit in specific), and for 32-bit Intel installs -- though any or all of these might be possible. MacPorts makes efforts to keep its ports working on all OSX from 10.4 through current, though some ports require an older version than current, or OS-specific patches. Hence, we recommend using MacPorts for older OSX installs as well as in general.
  
 
==X11/XQuartz or Terminal==
 
==X11/XQuartz or Terminal==
  
For the purposes of building and using UHD, you can use Apple's Terminal.app if you so choose, no matter how you install UHD.
+
For the purposes of building and using UHD, you can use Apple's Terminal.app if you so choose, no matter how you install UHD. Other terminal applications such as [https://iterm2.com iTerm2] work well too.
 
+
That said, running almost any graphical interface (GUI) will require downloading and installing X11/XQuartz first. Through OSX 10.8, Apple provided a means to install X11.app, but XQuartz has always been more up to date. Staring in 10.9, Apple no longer provides a full working version of X11.app. Hence, just use XQuartz from the get-go. Note that unless you experiment with using the Quartz interface to various graphical toolkits (e.g., GTK), you must use X11 as the terminal interface for any GUI applications.
+
  
 +
That said, running almost any graphical user interface (GUI) will require downloading and installing X11/XQuartz first. Through OSX 10.8, Apple provided a means to install the X11.app directly, but XQuartz has always been more up to date. Starting in OSX 10.9, Apple no longer provided X11.app. Hence, just use XQuartz from the get-go. Note that unless you experiment with using the Quartz interface to various graphical toolkits (e.g., GTK), you ''must'' use X11 as the terminal interface for any GUI applications for UHD and GNU Radio.
  
 
==Xcode==
 
==Xcode==
  
Apple provides a fully integrated development environment via their Xcode toolkit, which can be downloaded either via the App store or directly from Apple's Developer area depending on the version of OSX in use. Xcode provides the compilers and related development tools needed to build or execute UHD and its dependencies.
+
Apple provides a full integrated development environment via ''Xcode'', which can be downloaded either via the Mac App store or directly from Apple's Developer area depending on the version of OSX in use. Xcode provides the compilers and related development tools needed to build and execute UHD and its dependencies.
  
Once Xcode is installed, you must still install the Command Line Tools, which can be accomplished by running Xcode.app, then going to Preferences... -> Downloads and making sure Command Line Tools is selected/enabled [feel free to select other downloads too]. You might be able to install the Command Line Tools in a terminal using
+
Once Xcode is installed, you must still install the ''Command Line Tools'', which can be accomplished by executing the ''Xcode.app'', then going to ''Preferences...'' -> ''Downloads'' and making sure Command Line Tools is selected/enabled [feel free to select other downloads too]. You might be able to install the Command Line Tools in a terminal using the command
  
 
     xcode-select --install
 
     xcode-select --install
  
but this command will not work with every OSX / Xcode combination (e.g., does not work with OSX 10.8 and Xcode 5, but does work with OSX 10.9 and Xcode 5).
+
but this command will not work with every OSX / Xcode combination (e.g., does not work with OSX 10.8 and Xcode 5, but does work with OSX 10.9 and Xcode 5). More recent OSX provides the Command Line Tools via the Mac App Store.
 
+
Once the Command Line Tools are installed, UHD and other projects can be installed either from source or, preferably, via MacPorts.
+
  
 +
Once the Command Line Tools are installed, UHD and other projects can be installed either from source or, preferably, via a package manager such as MacPorts.
  
 
==UHD Software Installation on OS X==
 
==UHD Software Installation on OS X==
  
UHD can be installed via a package manager or from source.
+
UHD can be installed via a package manager or from source. For installing via a package manager we cover just via [https://macports.org/ MacPorts]; other package managers such as [http://www.finkproject.org/ Fink] or [https://brew.sh/ HomeBrew] might provide a means for installed UHD similar to that found in MacPorts. MacPorts tends to be more up-to-date with respect to new releases, which can be both a blessing and a curse since sometimes new released are untested and result in build or runtime errors. MacPorts, HomeBrew, and Fink offer thousands of ready-to-install libraries and applications, and hence they are highly recommended to use instead of installing from source / scratch.
  
 +
'''NOTE:''' We highly recommended that you install all dependencies via the ''same package manager''! When issues arise, the issues are much easier to track down, and updating UHD and any of its dependencies is also much easier.
  
==Via MacPorts==
+
===Via MacPorts===
  
We recommend using MacPorts and actively support UHD development on OS X via this method. Using MacPorts, the correct hardware device images are automatically installed for you, and there are no post install tasks. With a single command, you can be up and running in short order.
+
We recommend using MacPorts and actively support UHD development on OSX via this method. Using MacPorts, the correct hardware device images are automatically installed for you, and there are no post-install tasks. With a single command, you can be up and running in short order.
  
If you do not already have MacPorts installed, you will need to install it first. Make sure to follow the MacPorts shell environment changes needed such that MacPorts installed executables are found before all others. These are the only changes to the shell environment needed to execute any MacPorts-installed executable. Setting any DYLD environment variable (e.g., DYLD_LIBRARY_PATH) for general use is highly discouraged, because doing so, in our experience, leads to problems down the road that are very difficult to diagnose. OSX provides robust means for correcting DYLD-based issues even after dependencies are installed.
+
If you do not already have MacPorts installed, you will need to [https://www.macports.org/install.php install it first]. If required (such as installing MacPorts from source), follow the [https://guide.macports.org/#installing.shell MacPorts shell environment changes] guide such that MacPorts-installed executables are found before all others. These are the only changes to the shell environment needed to execute any MacPorts-installed executable.
 +
 
 +
'''NOTE:''' Setting any DYLD environment variable (e.g., ''DYLD_LIBRARY_PATH'') for general use is '''highly discouraged''', because doing so, in our experience, leads to problems down the road that are very difficult to diagnose. OSX provides robust means for correcting DYLD-based issues even after dependencies are installed.
  
 
Once MacPorts is installed, UHD and all of its dependencies can be installed by executing
 
Once MacPorts is installed, UHD and all of its dependencies can be installed by executing
Line 56: Line 69:
 
     sudo port install uhd
 
     sudo port install uhd
  
This method of installing UHD is actively kept up to date by Michael Dickens, and hence is the recommended way to install GNU Radio on OS X.
+
This method of installing UHD is actively kept up to date by Ettus Research technical support, and hence is the recommended way to install GNU Radio on OSX. GNU Radio can similarly be installed via
 +
 
 +
    sudo port install gnuradio
  
The latest developments in UHD can be installed via
+
The latest developments in UHD and GNU Radio can be installed via
  
 
     sudo port install uhd-devel
 
     sudo port install uhd-devel
 +
    sudo port install gnuradio-devel
  
Please note that the uhd-devel port, while tested for basic compilation and functionality, is not a formal release and hence should be considered beta software which might contain bugs or major issues.
+
Please note that the these ''devel'' ports, while tested for basic compilation and functionality, are not formal releases and hence should be considered beta software which might contain bugs or even major issues.
  
 +
===From Source===
  
==From Source==
+
====Background Dependencies====
  
==Background Dependencies==
+
There are a number of background libraries and applications that must be installed from source or binary in order to compile or execute UHD; a full list is provided in the [https://kb.ettus.com/UHD#Build_Dependencies UHD build guide]. These can be obtained by using a package manager and/or from source.  
 
+
There are a number of background libraries and applications that must be installed from source or binary in order to compile or execute UHD; a full list is provided in the UHD build guide. These can be obtained by using MacPorts, Fink, HomeBrew, and/or from source / scratch. MacPorts tends to be more up-to-date with respect to new releases, which can be both a blessing and a curse since sometimes new released are untested and result in build or runtime errors. MacPorts, HomeBrew, and Fink offer thousands of ready-to-install libraries and applications, and hence they are highly recommended to use instead of installing from source / scratch.
+
 
+
NOTE: We highly recommended that you install all dependencies via the same package manager! When issues arise, they are much easier to track down, and your updating to newer versions is also much easier.
+
  
 
Many UHD developers first install UHD using MacPorts in order to get all of the necessary background dependencies installed, then remove just UHD via
 
Many UHD developers first install UHD using MacPorts in order to get all of the necessary background dependencies installed, then remove just UHD via
Line 77: Line 90:
 
     sudo port uninstall uhd
 
     sudo port uninstall uhd
  
 +
===Compiling UHD from Source===
  
==Compiling UHD from Source==
+
Installing UHD from source follows the [https://files.ettus.com/manual/page_build_guide.html#build_instructions_unix standard ''cmake'' method], with a few arguments to make sure ''cmake'' always finds the Python executable, library, and headers ''from the same Python install'', and uses the desired compiler. First, download the source code either as a [http://files.ettus.com/binaries/uhd/ release] or [https://www.github.com/EttusResearch/uhd via GIT].
  
Installing UHD from source follows the standard cmake method as found in many places, with a few arguments to make sure cmake always finds the correct version of Python, and uses the desired compiler. First, download the source code either via a release or via GIT.
+
'''NOTE:''' All of the PYTHON defines must point to the same install of Python, otherwise runtime errors are likely to occur.
  
For example, on OSX 10.8 or 10.9 using Xcode 5's Apple GCC, MacPorts installed into /opt/local (the default), and for Python 2.7 (as installed by MacPorts), issue the following commands from within the UHD source directory:
+
For example, on OSX 10.14 or 10.15 using Xcode 11 (which provides the Clang compiler suite), MacPorts installed into ''/opt/local'' (the default), and for Python 2.7 (as installed by MacPorts), issue the following commands from within the UHD source top-level directory:
  
 
     $ mkdir build
 
     $ mkdir build
  
     $ cd build $ CC=/usr/bin/llvm-gcc CXX=/usr/bin/llvm-g++ cmake -DPYTHON_EXECUTABLE=/opt/local/bin/python2.7 \
+
     $ cd build
    -DPYTHON_INCLUDE_DIR=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Headers \
+
 
    -DPYTHON_LIBRARY=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Python ../host
+
    $ CC=/usr/bin/clang CXX=/usr/bin/clang++ \
 +
      cmake -DPYTHON_EXECUTABLE=/opt/local/bin/python2.7 \
 +
      -DPYTHON_INCLUDE_DIR=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Headers \
 +
      -DPYTHON_LIBRARY=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Python ../host
  
 
     $ make
 
     $ make
  
If make succeeds, then you can test the build for errors via
+
If ''make'' succeeds, then you can test the build for errors via
  
 
     $ make test
 
     $ make test
Line 100: Line 117:
 
     $ sudo make install
 
     $ sudo make install
  
Selecting another compiler is as simple as changing the CC and CXX pre-arguments to the cmake command. Note that all of the PYTHON defines must point to the same install of Python, otherwise runtime errors are likely to occur.
+
and UHD will be installed into the default prefix, ''/usr/local'' .
 +
 
 +
'''NOTE:''' To change the install prefix to ''/path/to/your/desired/prefix'' , in the ''cmake'' command add the argument ''-DCMAKE_INSTALL_PREFIX=/path/to/your/desired/prefix'' -- changing the actual path to that of the desired install prefix.
 +
 
 +
'''NOTE:''' If you want to test where the install will place files, you can set a destination directory that the install prefix is appended to via using the pre-argument ''DESTDIR''. To verify that all files are installed and then uninstalled corrected, we often use the following command
 +
 
 +
    $ DESTDIR=./tmp make install
 +
 
 +
and then look in the directory ''./tmp'' to verify that all of the desired files are installed into their final destination correctly, starting with the ''CMAKE_INSTALL_PREFIX''. Then, issue the command
  
 +
    $ DESTDIR=./tmp make uninstall
  
 +
to uninstall from the same directory. Then look in the directory ''./tmp'' to see if any files remain, and if so then fix the CMake scripts to both install and uninstall all of the desired files correctly.
  
 +
'''NOTE:''' Selecting another compiler is as simple as changing the ''CC'' and ''CXX'' pre-arguments to the ''cmake'' command.
  
 +
==Installing GNU Radio on OSX==
  
 +
See the [https://wiki.gnuradio.org/index.php/MacInstall GNU Radio OSX Install guide].
  
 
[[Category:Application Notes]]
 
[[Category:Application Notes]]

Latest revision as of 11:34, 15 February 2021

Application Note Number and Author

AN-788 by Michael Dickens

Abstract

This AN provides a comprehensive step-by-step guide for installing UHD (and GNU Radio) on OSX (Mac OS X / MacOS X 10.4 to 10.15) and macOS 11 or newer -- whether via a package manager or from source.

UHD on OSX / macOS

UHD 3.9, 3.15, and 4.0 have been compiled and installed on OSX 10.4 ("Tiger") and 10.5 ("Leopard") for PowerPC or Intel 32-bit, OSX 10.6 ("Snow Leopard") through the OSX 10.15 ("Catalina") for Intel 64-bit, as well as macOS 11 ("Big Sur") Intel or ARM 64-bit running any compatible version of Xcode on all recent and many older Macs. In general UHD performance varies greatly depending on the computer's OS, CPU, and networking stack and hardware for ethernet and USB. For Macs there is more consistency between hardware and OS versions because of Apple's tight coupling of hardware and software; hence the broad OSX and hardware support for UHD.

Primary support is for 64-bit Intel-based Macs, running OSX 10.9 or newer using Clang / libc++; secondary support is for OSX 10.6 through 10.8 64-bit Intel-based Macs using Xcode's default GCC / libstdc++ or specially-installed Clang / libc++ (e.g., via MacPorts); tertiary support is for OSX 10.4 and 10.5 Intel or PowerPC 32-bit using Xcode's default GCC / libstdc++ (as of early 2021, Clang does not yet build reliably for these older OSX). There is very little support for getting the background libraries and applications installed on OSX 10.4 or 10.5 (in general, and for 64-bit in specific), and for 32-bit Intel installs -- though any or all of these might be possible. MacPorts makes efforts to keep its ports working on all OSX from 10.4 through current, though some ports require an older version than current, or OS-specific patches. Hence, we recommend using MacPorts for older OSX installs as well as in general.

X11/XQuartz or Terminal

For the purposes of building and using UHD, you can use Apple's Terminal.app if you so choose, no matter how you install UHD. Other terminal applications such as iTerm2 work well too.

That said, running almost any graphical user interface (GUI) will require downloading and installing X11/XQuartz first. Through OSX 10.8, Apple provided a means to install the X11.app directly, but XQuartz has always been more up to date. Starting in OSX 10.9, Apple no longer provided X11.app. Hence, just use XQuartz from the get-go. Note that unless you experiment with using the Quartz interface to various graphical toolkits (e.g., GTK), you must use X11 as the terminal interface for any GUI applications for UHD and GNU Radio.

Xcode

Apple provides a full integrated development environment via Xcode, which can be downloaded either via the Mac App store or directly from Apple's Developer area depending on the version of OSX in use. Xcode provides the compilers and related development tools needed to build and execute UHD and its dependencies.

Once Xcode is installed, you must still install the Command Line Tools, which can be accomplished by executing the Xcode.app, then going to Preferences... -> Downloads and making sure Command Line Tools is selected/enabled [feel free to select other downloads too]. You might be able to install the Command Line Tools in a terminal using the command

   xcode-select --install

but this command will not work with every OSX / Xcode combination (e.g., does not work with OSX 10.8 and Xcode 5, but does work with OSX 10.9 and Xcode 5). More recent OSX provides the Command Line Tools via the Mac App Store.

Once the Command Line Tools are installed, UHD and other projects can be installed either from source or, preferably, via a package manager such as MacPorts.

UHD Software Installation on OS X

UHD can be installed via a package manager or from source. For installing via a package manager we cover just via MacPorts; other package managers such as Fink or HomeBrew might provide a means for installed UHD similar to that found in MacPorts. MacPorts tends to be more up-to-date with respect to new releases, which can be both a blessing and a curse since sometimes new released are untested and result in build or runtime errors. MacPorts, HomeBrew, and Fink offer thousands of ready-to-install libraries and applications, and hence they are highly recommended to use instead of installing from source / scratch.

NOTE: We highly recommended that you install all dependencies via the same package manager! When issues arise, the issues are much easier to track down, and updating UHD and any of its dependencies is also much easier.

Via MacPorts

We recommend using MacPorts and actively support UHD development on OSX via this method. Using MacPorts, the correct hardware device images are automatically installed for you, and there are no post-install tasks. With a single command, you can be up and running in short order.

If you do not already have MacPorts installed, you will need to install it first. If required (such as installing MacPorts from source), follow the MacPorts shell environment changes guide such that MacPorts-installed executables are found before all others. These are the only changes to the shell environment needed to execute any MacPorts-installed executable.

NOTE: Setting any DYLD environment variable (e.g., DYLD_LIBRARY_PATH) for general use is highly discouraged, because doing so, in our experience, leads to problems down the road that are very difficult to diagnose. OSX provides robust means for correcting DYLD-based issues even after dependencies are installed.

Once MacPorts is installed, UHD and all of its dependencies can be installed by executing

   sudo port install uhd

This method of installing UHD is actively kept up to date by Ettus Research technical support, and hence is the recommended way to install GNU Radio on OSX. GNU Radio can similarly be installed via

   sudo port install gnuradio

The latest developments in UHD and GNU Radio can be installed via

   sudo port install uhd-devel
   sudo port install gnuradio-devel

Please note that the these devel ports, while tested for basic compilation and functionality, are not formal releases and hence should be considered beta software which might contain bugs or even major issues.

From Source

Background Dependencies

There are a number of background libraries and applications that must be installed from source or binary in order to compile or execute UHD; a full list is provided in the UHD build guide. These can be obtained by using a package manager and/or from source.

Many UHD developers first install UHD using MacPorts in order to get all of the necessary background dependencies installed, then remove just UHD via

   sudo port uninstall uhd

Compiling UHD from Source

Installing UHD from source follows the standard cmake method, with a few arguments to make sure cmake always finds the Python executable, library, and headers from the same Python install, and uses the desired compiler. First, download the source code either as a release or via GIT.

NOTE: All of the PYTHON defines must point to the same install of Python, otherwise runtime errors are likely to occur.

For example, on OSX 10.14 or 10.15 using Xcode 11 (which provides the Clang compiler suite), MacPorts installed into /opt/local (the default), and for Python 2.7 (as installed by MacPorts), issue the following commands from within the UHD source top-level directory:

   $ mkdir build
   $ cd build
   $ CC=/usr/bin/clang CXX=/usr/bin/clang++ \
      cmake -DPYTHON_EXECUTABLE=/opt/local/bin/python2.7 \
     -DPYTHON_INCLUDE_DIR=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Headers \
     -DPYTHON_LIBRARY=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Python ../host
   $ make

If make succeeds, then you can test the build for errors via

   $ make test

To install the build, issue

   $ sudo make install

and UHD will be installed into the default prefix, /usr/local .

NOTE: To change the install prefix to /path/to/your/desired/prefix , in the cmake command add the argument -DCMAKE_INSTALL_PREFIX=/path/to/your/desired/prefix -- changing the actual path to that of the desired install prefix.

NOTE: If you want to test where the install will place files, you can set a destination directory that the install prefix is appended to via using the pre-argument DESTDIR. To verify that all files are installed and then uninstalled corrected, we often use the following command

   $ DESTDIR=./tmp make install

and then look in the directory ./tmp to verify that all of the desired files are installed into their final destination correctly, starting with the CMAKE_INSTALL_PREFIX. Then, issue the command

   $ DESTDIR=./tmp make uninstall

to uninstall from the same directory. Then look in the directory ./tmp to see if any files remain, and if so then fix the CMake scripts to both install and uninstall all of the desired files correctly.

NOTE: Selecting another compiler is as simple as changing the CC and CXX pre-arguments to the cmake command.

Installing GNU Radio on OSX

See the GNU Radio OSX Install guide.