GNU Radio on Mac OS X: Installing the Prerequisites

Jon Jacky

4 Jan 2010   Emphasize this page is for OS X 10.4 only, also change gnuradio.org/trac to /redmine


To install GNU Radio on recent Mac hardware and operating systems, consult the Build Guide and Mac Install pages at the GNU Radio Wiki:

http://vps.gnuradio.org/redmine/wiki/gnuradio/BuildGuide,   MacInstall

These pages describe our installation of GNU Radio 3.0 and 3.1 with the USRP hardware on Mac OS X 10.4 Tiger on PPC Macs.

Rationale Python Xcode Subversion MacPorts autotools swig Core libraries NumPy wxPython libusb SDCC Next steps

Rationale

The prerequisites are tools and libraries needed to install or use GNU Radio. They can be useful for other purposes also.

Obtaining and installing the prerequisites is more work than installing GNU Radio itself. However, it rarely needs to be repeated. To build and use recent versions of GNU Radio, we still use many of the prerequisites we installed in 2005.

Many prerequisites are available in several formats. Here are the alternatives, ranked from easiest to most difficult to install.

  1. Already included in OS X or provided by Apple
  2. MacPorts port
  3. Binary distribution for OS X (usually a .dmg file)
  4. source distribution (usually a .tar file)

We usually choose the easiest format, but sometimes the version required by GNU Radio is only available in a more difficult format.

Install the prerequisites from an admin account. If a command fails because of permission or privilege problems, try again with sudo command.

Python

We don't install Python, we use the version that already comes with OS X. Currently we are running OS X version 10.4.10, which provides Python 2.3.5.

At this writing the latest Python version is 2.5, but 2.3.5 is sufficient to build and run the latest GNU Radio. It is possible to install a newer version of Python on OS X in addition to the one that is provided, but this can create difficulties, so we have chosen not to.

Sticking with Python 2.3.5 can be a bit inconvenient because some versions of other prerequisites depend on more recent Python versions. However, we have always been able to find a version of every prerequisite that works with Python 2.3.5. Details follow.

Xcode

We installed Apple's Xcode programming tools and libraries. Xcode provides gcc 4.0 and make. The Xcode tools install in /usr/bin.

We don't use the Xcode GUI to build or install GNU Radio. We do it all from the command line, in a terminal window.

Xcode 2.0 comes on the Tiger install DVD, but it is not installed automatically along with Tiger. After you install Tiger, load the Tiger DVD. Open the Xcode Tools folder; in that folder open XCodeTools.mpkg to start the Xcode Tools Installer, then follow its directions. After the installation completes, run update (Apple Menu -> Software Update ...) to get up to the latest version.

Alternatively, you can download the latest version of Xcode from the following URL at Apple. It's free, but you must register for Apple Developer Connection.

http://developer.apple.com/tools/download/

At this writing (March 2008), Xcode 2.5 is the latest version for OS X version 10.4 (Tiger). There is a 3.0 version, but it is only for 10.5 (Leopard).

Download the Xcode DMG (disk image) file. Opening this file mounts the Xcode Tools disk. On that disk, open XCodeTools.mpkg to start the Xcode Tools Iinstaller, then follow its directions. When the installation is finished, you can eject the disk (ctrl-Click, select Eject from the menu, or drag the disk icon to the trash).

Subversion

We installed the Subversion (svn) version control system to check out the GNU Radio source code and build scripts from the repository. GNU Radio no longer uses CVS.

Here we found a .dmg file that you can install in the usual way.

http://metissian.com/projects/macosx/subversion/

Here is the main Subversion web site.

http://subversion.tigris.org/

MacPorts

MacPorts is a collection of open-source software packaged for Mac OS X. Get a package from MacPorts if you can; this is usually more convenient and less error-prone than building it from source. Most of the prerequisites for GNU Radio are available from MacPorts.

MacPorts also refers to the package management tools. They maintain a database of packages available on the Internet and a registry of packages installed on your machine. The MacPorts port command is analogous to the rpm, apt-get, or dpkg commands available on some Linux systems. Use it to find, install, and query about the MacPorts software packages. The port install package command downloads and installs package, and any other packages on which it depends.

The MacPorts software packages (including the MacPorts tools themselves) install under /opt/local. This directory does not exist when Mac OS X is installed. Installing the MacPorts tools creates it (if it has not already been created for some other reason).

Install the MacPorts tools first. Go to the Get MacPorts page and follow the directions there.

http://www.macports.org/install.php

After the installation completes, run the command

sudo port -d selfupdate

to bring your installation up to date.

When you use MacPorts, the directory /opt/local/bin must be in your PATH so your process can find the MacPorts tools. This directory must appear before /usr/bin in your PATH, so you will be sure to use the MacPorts version of a tool rather than any older version that might be provided by Xcode. You can ensure this by putting a line like this one in your .profile file.

export PATH=/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:~/bin:/usr/local/bin:... other directories ...

Here are some useful MacPorts commands. MacPorts calls a package a port; its name is its portname.

man port List information about the port command.
port list List all available ports (a great many!)
port search regexp List all available ports whose names match the regular expression
port installed List installed ports
port info portname List information about portname (any available, not just installed)
port deps portname List dependencies, other ports required to build and run portname
port install portname Download and install portname (and any ports on which it depends)
port contents portname List files installed by portname
port dependents portname List installed ports that depend on portname
port provides filename Name the port that installed filename
port -d selfupdate Update MacPorts tools and database
port -a upgrade Upgrade all outdated ports (after selfupdate)
port -u uninstall Uninstall all installed but inactive ports (after upgrade)

autotools

The autotools are programs that automate building software packages on multiple platforms. They are needed to build GNU Radio.

GNU Radio requires these tools and versions, according to the README in the top-level gnuradio build directory.

autonconf 2.57 or later
automake 1.7.4 or later
libtool 1.5 or later
pkgconfig 0.15.0 or later

All of the autotools are available from MacPorts. To install the autotools, execute the following commands:

$ sudo port install autoconf
... 
$ sudo port install automake
...
$ sudo port install libtool
...
$ sudo port install pkgconfig
...
Confirm that you have succesfully installed the autotools:
$ port installed
The following ports are currently installed:
  autoconf 2.59_0 (active)
  automake 1.9.5_0 (active)
  libtool 1.5.20_0 (active)
  pkgconfig 0.19_0 (active)

Confirm that your PATH is set correctly, so you execute the MacPorts versions and not any older Xcode versions.

$ which automake
/opt/local/bin/automake
$ automake --version
automake (GNU automake) 1.9.5
...

Contrast this to the older version installed by Xcode, which will not build GNU Radio.

$ /usr/bin/automake --version
automake (GNU automake) 1.6.3

swig

Swig is a tool that enables Python code to call C++ code. GNU Radio requires swig 1.3.23 or later.

Swig is available from MacPorts. Install it and confirm the installation in the usual way.

$ sudo port install swig
...
$ port installed
...
  swig 1.3.25_0 (active)

Core libraries

Several libraries are required to build gnuradio-core:

Boost C++ libraries 1.31 recommended, presumably later is OK
cppunit 1.9.14 or later
FFTW3 3.0 or later

These are all available from MacPorts. Boost and cppunit can be installed and confirmed as usual.

$ sudo port install boost
...
$ sudo port install cppunit
...
$ port installed
...
  boost 1.32.0_0 (active)
  boost-jam 3.1.11_0 (active)
  cppunit 1.11.0_0 (active)

These installations can take many minutes so be patient and don't panic. You can view the output of top -o cpu in a different window to reassure yourself that the installation in proceeding.

To get the right version of FFTW3, install the MacPorts fftw-3-single package (thanks to Michael Dickens for pointing this out).

$ sudo port install fftw-3-single
...

When the installation completes, make sure you have the libfftw3f libraries (with an f at the end of the name), not libfftw3.

$ port contents fftw-3-single
Port fftw-3-single contains:
  ...
  /opt/local/lib/libfftw3f.a
  /opt/local/lib/libfftw3f.la
  /opt/local/lib/libfftw3f_threads.a
  /opt/local/lib/libfftw3f_threads.la
  /opt/local/lib/pkgconfig/fftw3f.pc
  ...

NumPy and SciPy

NumPy is a Python numeric library. It is required to run both gnuradio-core and gr-wxgui (it is not required to build them).

GNU Radio no longer uses Numeric. NumPy has replaced Numeric.

We also use SciPy, a scientific programming package that uses NumPy. SciPy is not required by GNU Radio itself, but it is required by our MRFM software.

To install NumPy, SciPy, and their prerequisites we followed these directions:

http://www.scipy.org/Installing_SciPy/Mac_OS_X

except we declined their recommendation to install a newer Python. In summary:

  1. Following the recommendation on compilers in the SciPy FAQ at

    http://www.scipy.org/FAQ#head-f94e8674db29e47e399dc7390f8c1e0f708ab7f2

    we build everything with GCC 3.3:

    $ sudo gcc_select 3.3
    $ gcc -dumpversion    # check GCC version 
    3.3
    
  2. Download the g77 Fortran binary g77-bin.tar.gz from the link on

    http://hpc.sourceforge.net/

  3. and install it using the instructions on that same page.

  4. Download the FFTW library source fftw-3.1.2.tar.gz from

    http://fftw.org/fftw-3.1.2.tar.gz

    and install using the instructions on Installing_SciPy/Mac_OS_X

    We already installed an FFTW library from MacPorts for GNU Radio, but SciPy needs this different version of FFTW, and looks for it in a different place.

  5. Download the NumPy source numpy-1.0.1.tar.gz from the link on

    http://www.scipy.org/Download

    and install using the instructions on Installing_SciPy/Mac_OS_X

  6. Download the SciPy source scipy-0.5.2.tar.gz from the link on

    http://www.scipy.org/Download

    and install using the instructions on Installing_SciPy/Mac_OS_X. Note the special instruction for g77.

We installed these in March 2007. More recent versions of some packages are now available.

wxPython

wxPython provides the GUI for GNU Radio. It is a prerequisite for the gr-wxgui module only. You don't need wxPython to build and use gnuradio-core.

wxPython is available as the MacPorts package py-wxpython, but this package requires python24, so we don't use it. The version we run uses the Mac's already installed Python 2.3.

We are using version wxPython 2.6.1.0, which we installed in August 2005. At this writing, it still works with recent versions of GNU Radio (trunk, and 3.1 stable branch). We see the latest version is 2.8, which is available for Python 2.3 on OS X.

Get the binary disk image for the Mac from the wxPython download page.

http://www.wxpython.org/download.php#binaries

From this page, find the section Mac OS X, wxPython Runtime, Panther (10.3.X). Follow the link osx-ansi. It leads to a SourceForge page with a lot of mirrors, pick one and download the disk image (.dmg) file. Open this file to mount the wxPython installation disk. On that disk, open the wxPython .pkg file to start the installer, then follow its directions.

When the installation completes you will have many new executables and .py files in /usr/local/bin, a new directory and contents /usr/local/lib/wxPython-ansi-version, a new directory and contents /Library/Python/2.3/wx-version-mac-ansi and other new files in /Library/Python/2.3.

You can also get documentation, demos, and samples from the wxPython downloads page by following osx-docs-demos, but these are not needed by GNU Radio.

The version we are using, wxPython 2.6.1.0, was developed for Mac OS X 10.3 (Panther). To make it run under 10.4 (Tiger), we had to install another package from the wxPython site (you can also reach it by following links starting at the wxPython downloads page):

http://pythonmac.org/packages/

Scroll down to TigerPython23Compat and download the .pkg.zip file. On download, it unzips and the installation begins. Follow the prompts. It installs the file _TigerPython2.3Compat.pth under /Library/Python/2.3/site-packages

Check that installation succeeded by typing this command at the shell prompt:

$ pyshell

A python shell window should open up. (We don't use this command, we always run Python from a terminal window).

Now we have all the prerequisites we need to install and use the gr-wxgui module.

libusb

To use the USRP hardware, you must have libusb. It is a prerequisite for the usrp module. Get it from MacPorts.

$ port info libusb
libusb 0.1.10a, ....

$ sudo port install libusb
...

$ port installed
  ...
  libusb 0.1.10a_1 (active)
  ...

$ port contents libusb
Port libusb contains:
  ...
  /opt/local/bin/libusb-config
  /opt/local/include/usb.h
  /opt/local/include/usbpp.h
  ...
  /opt/local/lib/libusb.dylib
  ...
  /opt/local/lib/libusbpp.dylib
  ...
We still need one more prerequisite for the usrp module.

SDCC

SDCC is the small computer compiler collection. It is a prerequisite for the usrp module. Get it from MacPorts. SDCC might require some tweaking. The installation might fail, like this:
$ port install sdcc
--->  Fetching sdcc
--->  Attempting to fetch sdcc-2.4.0.tar.gz from http://puzzle.dl.sourceforge.net/sdcc
--->  Verifying checksum(s) for sdcc
--->  Extracting sdcc
--->  Configuring sdcc
--->  Building sdcc with target all
Error: Target com.apple.build returned: shell command "cd /opt/local/var/db/dports/build/file._opt_local_var_db_dports_sources_rsync.rsync.opendarwin.org_dpupdate_dports_lang_sdcc/work/sdcc && gnumake all" returned error 2
...
... many successful gcc commands
... 
gcc -Wall -pipe -ggdb -g -O2  -I. -I.. -I../support/Util -c SDCCutil.c -o SDCCutil.o
In file included from SDCCutil.c:30:
../support/Util/dbuf.h:32: error: parse error before 'size_t'
../support/Util/dbuf.h:32: warning: no semicolon at end of struct or union
../support/Util/dbuf.h:33: warning: type defaults to 'int' in declaration of 'len'
../support/Util/dbuf.h:33: warning: data definition has no type or storage class
../support/Util/dbuf.h:35: error: parse error before '}' token
../support/Util/dbuf.h:42: error: parse error before 'size'
../support/Util/dbuf.h:43: error: parse error before 'size_t'
../support/Util/dbuf.h:44: error: parse error before 'size_t'
../support/Util/dbuf.h:45: error: parse error before 'size_t'
../support/Util/dbuf.h:47: error: parse error before 'dbuf_get_size'
../support/Util/dbuf.h:47: warning: type defaults to 'int' in declaration of 'dbuf_get_size'
../support/Util/dbuf.h:47: warning: data definition has no type or storage class
SDCCutil.c: In function 'appendStrSet':
SDCCutil.c:74: error: storage size of 'dbuf' isn't known
SDCCutil.c:74: warning: unused variable 'dbuf'
SDCCutil.c: In function 'joinStrSet':
SDCCutil.c:97: error: storage size of 'dbuf' isn't known
SDCCutil.c:97: warning: unused variable 'dbuf'
gnumake[1]: *** [SDCCutil.o] Error 1
gnumake: *** [sdcc-cc] Error 2

To recover from this, go to the directory that contains SDCCutil.c, which is

/opt/local/var/db/dports/build/_opt_local_var_db_dports_sources_rsync.rsync.darwinports.org_dpupdate_dports_lang_sdcc/work/sdcc/src/

Edit SDCCutil.c (with sudo). Search for dbuf.h, and move that whole line to the end of the #include's (4 lines below).

Then, repeat the install command. It should resume at the step that failed, and complete successfully. (Thanks to Michael Dickens for this fix.)

$ port install sdcc
--->  Building sdcc with target all--->  Staging sdcc into destroot
--->  Packaging tgz archive for sdcc 2.4.0_0
--->  Installing sdcc 2.4.0_0
--->  Activating sdcc 2.4.0_0
--->  Cleaning sdcc

$ port installed
  ...
  sdcc 2.4.0_0 (active)
  ...

If the SDCC install still fails, you may have to assign these environment variables:

  SDCC_LIB=/opt/local/share/sdcc/lib/
  SDCC_INCLUDE=/opt/local/share/sdcc/include/

See thread starting at:

http://lists.gnu.org/archive/html/discuss-gnuradio/2006-01/msg00167.html

Now we have all the prerequisites we need for the USRP modules.

Next steps

Instructions for subsequent steps:

Installing GNU Radio Using the GUI Using the USRP


Jon Jacky, jon@u.washington.edu