Building and Running Fldigi on Raspberry Pi

Matt Roberts - matt-at-kk5jy-dot-net

Published: 2017-07-10

Updated: 2018-01-27

Recent versions of the Raspberry Pi single-board computers feature enough CPU power to run the Fldigi digital mode software.  In particular, the RasPi 3 features a powerful quad-core ARM CPU.  This is an important step forward, because it allows a low-power computer to do everything needed to add HF digial mode support to an HF radio, without the need for a notebook or desktop computer.  The RasPi computers are small, and can be easily mated with a touch screen and just about any kind of keyboard, making a very compact, portable or mobile terminal for digital modes.

One challenge with fldigi, however, is that the packages traditionally included in the Raspbian repositories are quite old, while the Fldigi package changes regularly.  What I have found is that the best way to get Fldigi running on the RasPi is to build it from source.  This is a step-by-step guid on how to do this.

These steps should work with little or no modification on other RasPi distributions, and they should work even for PC users.  The main differences, if any, will be in the package names of prerequisites.

The Basics

This guide assumes that you have a Raspberry Pi 3, running Raspbian Jessie, and that you have already completed the installation process.  It also assumes that you have the graphical desktop running.  To build Fldigi, you will need the build-essentials meta-package installed, but this is the default for recent versions of Raspbian Jessie.

Getting the Source

The Fldigi website has links to download the various source packages.  Here I'll assume that we'll build fldigi and flrig, which are the packages I use the most.  We'll also build the hamlib package which is available from its own SourceForge page.  The files to be downloaded include:
You are, of course, free to download newer versions, but these are the versions I have been able to make work on the hardware.  If you use a newer version, don't forget to use the newer version number in each of the steps below.

Place all four files in your home directory on the RasPi, which is probably /home/pi.

Prerequisite Packages

The Fldigi build process requires a number of prerequisites.  These include GUI, image, and sound libraries, among others.  The build also requires that you build an XMLRPC library written by the Fldigi team.

Installing and building the prerequisite packages should be done at a command prompt, most likely a terminal.  One step that I like to perform before building fldigi is to set some compiler optimization flags, so that the compiled code will be the most efficient for the RasPi.  If you elect this step, you'll need to determine the proper flags for your machine, but I have found that these work best for the RasPi3:
export CXXFLAGS='-O2 -march=armv8-a -mtune=cortex-a53'
export CFLAGS='-O2 -march=armv8-a -mtune=cortex-a53'
These need to be entered before building packages, in order to have any effect.  Some versions of GCC are able to determine the best optimization flags on their own, particularly when building on a PC.  The best flags to use, when this is supported, are:
export CXXFLAGS='-O2 -march=native -mtune=native'
export CFLAGS='-O2 -march=native -mtune=native'
When the 'native' architecture keyword is used, GCC will attempt to determine the best architecture flags dynamically at build time.

First, let's install the prerequisite system packages.  These are packages that are maintained by the Raspbian team, and can be installed using apt-get.  The only requirement is that the RasPi needs to have some kind of Internet access, so it can download the packages from the Raspbian repositories.

At a terminal prompt, run the following commands, one after another.
sudo apt-get update
sudo apt-get install libfltk1.3-dev
sudo apt-get install libjpeg9-dev
sudo apt-get install libxft-dev
sudo apt-get install libxinerama-dev
sudo apt-get install libxcursor-dev
sudo apt-get install libsndfile1-dev
sudo apt-get install libsamplerate0-dev
sudo apt-get install portaudio19-dev
sudo apt-get install libpulse-dev
Some of these packages may already be installed.  If any of these commands responds with "package is already the newest version", just skip to the next one.

Some of these packages may have other dependencies, so each command may install more than one package. This is normal, so just sit back and watch it all install.

Not all of the above packages are required for all configurations of fldigi, but all of them should be safe to install, whether you use the associated features or not.

The first source prerequisite is the XMLRPC library from the Fldigi team.  We'll need to extract the source, configure it, build it, and install it.  At the same command prompt, run the following commands, one at a time.
tar -zxvf flxmlrpc-0.1.4.tar.gz
cd flxmlrpc-0.1.4
./configure --prefix=/usr/local --enable-static
sudo make install
sudo ldconfig
cd ..
Next, we'll build the hamlib package, just like with the XMLRPC package.  While the Raspbian distribution includes a build of hamlib, it is rather old, and doesn't include many radios from the last several years.  So when I build fldigi, I build a more recent version of hamlib, to run my newer radios. First, make sure that hamlib isn't already installed:
sudo apt-get remove libhamlib2
If this gives you a message saying that the package wasn't installed, you're done.  Otherwise the system will prompt you to uninstall the package.

Then we build its replacement:
tar -zxvf hamlib-3.1.tar.gz
cd hamlib-3.1
./configure --prefix=/usr/local --enable-static
sudo make install
sudo ldconfig
cd ..
At this point, the packages needed to build any of the fldigi family of programs should be available on your system.

Building Flrig

Next, let's build Flrig.  As before, run the following:
tar -zxvf flrig-1.3.31.tar.gz
cd flrig-1.3.31
./configure --prefix=/usr/local --enable-static
sudo make install
cd ..
Flrig is self-contained, so you should be able to run it already, even though we haven't yet built fldigi:
Which should result in the flrig root window:

Building Fldigi

Finally, we build Fldigi itself. Let's do this in two steps. First, extract the source and configure it, as we did with the other packages: 
tar -zxvf fldigi-4.0.4.tar.gz
cd fldigi-4.0.4
./configure --prefix=/usr/local --enable-static
At this point, verify that the configuration was able to pick up all of the supported libraries.  You should see this towards the end of the configuration process:
Configuration summary:

  Version ..................... 4.0.4

  Static linking .............. yes
  CPU optimizations ........... none
  Debugging ................... no

  fldigi ...................... yes
  flarq ....................... yes

  i18n ........................ yes

  fldigi build options:

  sndfile ..................... yes
  oss ......................... yes
  portaudio ................... yes
  pulseaudio .................. yes

  flxmlrpc .................... yes

  hamlib ...................... yes
Note that the fldigi build options section items all show yes.  This is what you want.  If something shows as no, you'll have to do some troubleshooting to see why the associated library wasn't picked up.  Also, note that CPU optimizations shows as none, even though we set CFLAGS and CXXFLAGS.  This is normal, and the CFLAGS and CXXFLAGS set above will be used during the build.  Once you are satisfied with the configuration, go ahead and build:
sudo make install
cd ..
At this point, fldigi is installed, and you can run it from the command line:
...which should result in an initial configuation window:

Fldigi Configuration

My suggestion is that you only fill in basic configuration options during the first startup, e.g., enter your callsign and basic information, but don't try to configure soudcards, radios, PTT, etc. Once you get the fldigi root window, exit the application to save the basic configuration.  Then start fldigi again, and start working on configuring hardware.  The reason I say this is that fldigi, as great as it is, can be rather buggy when configuring hardware options, and if a setting causes fldigi to crash, you don't want to lose everything else you configured.  This can be even more important on a resource-constrained machine like the RasPi.

If all goes well, you should be rewarded with the fldigi main window:

Fldigi Root Window

The Raspberry Pi, like many SBCs, is a hobbyist board.  If something goes wrong, you may have to do a little troubleshooting to figure out what needs adjustment.  Hardware in particular can be a bit of a challenge, finding serial ports, sound card names, etc. Don't be afraid to experiment.

The fldigi package can be quite capable for low-power operations.  I have run contests using fldigi on the RasPi 3, while portable in a state park, and it is a very rewarding experience to be able to do digital modes without a full-sized computer.

Copyright (C) 2017 by Matt Roberts, KK5JY.
All Rights Reserved.