journal of recreational computer science

home

Running SDRSharp on Mac OS X

22 Feb 2014

A while back I bought one of those £15 DVB-T dongles to see if they're good for anything. Turns out, they're pretty amazing devices, and you can't possibly beat the price given its capabilities.

Sadly, the variety of software available for the Mac leaves much to be desired. Apart from the rtlsdr suite and Gqrx, there are very few programs available.

This evening, I turned my attention to SDRSharp - an SDR suite originally targeted at the Windows platform, written in C#. Immediately, I thought of Mono, and if it would be possible to run SDRSharp on a Mac, given a Mono runtime. Mind you - the last time I looked at Mono (around 2006), the folks behind it were working on reimplementing Windows.Forms, so it wasn't exactly ready for the prime time back then.

This writeup describes how to get SDRSharp up and running on Mac OS X

Download the Mono platform and install Xamarin Studio.

First, you'll need to download the Mono runtime (an equivalent of the .NET Framework for platforms other than Windows). Head over to the project page and select Mac OSX - there are two packages to download and install:

Install the portaudio and rtlsdr libraries.

In order to talk to your dongle, you'll need a library (rtl-sdr) which exposes an abstraction layer and talks to the dongle using libusb. Since this is a native library (compiled for a particular platform - in our case Mac OS X), you'll need to build it from scratch using MacPorts. SDRSharp uses P/Invoke facilities to talk to the libraries in question. All you need to do is build them for the right architecture (i386).

Assuming you have MacPorts installed, simply issue the following commands. The +universal variant is important.

$ sudo port install portaudio +universal
$ sudo port install rtl-sdr +universal

Building the latter may take a while, or at least it did in my case - ImageMagick was rebuilt among others (go figure).

Get the SDRSharp sources.

In a directory of your choice, run the following:

$ svn co https://subversion.assembla.com/svn/sdrsharp/trunk sdrsharp

This will pull the latest SDRSharp sources from the repository.

Build the SDRSharp binary.

Fire up Xamarin Studio, open an existing project and select SDRSharp.sln in the sdrsharp directory you just checked out. Change the active configuration (Project | Active Configuration) to Release|x86. Then select Build | Build All and give it a minute or so to build everything.

Set up symbolic links to the libraries you've installed above.

This will tell the mono runtime where to load the native libraries from. You will need at least portaudio -- the latter is only required if you want to use the USB dongle.

$ ln -s /opt/local/lib/libportaudio.2.dylib libportaudio.dylib
$ ln -s /opt/local/lib/librtlsdr.0.5git.dylib librtlsdr.dylib

Run it.

Head over to the sdrsharp/Release directory and run:

mono SDRSharp.exe

edit: Eric Brombaugh pointed out the following:

edit: Increasing performance

You may try your luck by precompiling the executable with mono --aot=full -O=all SDRSharp.exe. This will prevent the mono runtime from executing its JIT compiler, potentially leading to increased performance (it appears to help on my old Mac Mini, but YMMV). You'd then run the binary with mono SDRSharp.exe - the precompiled code will be executed automatically.