28 Mar 2019

Compiling Fldigi 4.1.01 on Raspbian Stretch

Posted by khk

After getting Fldigi 4.1.01 to compile on macOS, I tried it on my Raspberry Pi running Raspbian Stretch. I never had a problem compiling versions 4.0.xx, but when I first tried to build the new version, I ended up with an error message:

make[3]: Entering directory '/home/pi/radio/fldigi-4.1.01/src'
  CXX      dialogs/fldigi-confdialog.o
virtual memory exhausted: Cannot allocate memory

The term “virtual memory” pointed me in the right direction: In a very simplistic view, virtual memory is the sum of real memory and the size of the swap file/partion on a Unix system. The error message indicates that I did not have enough virtual memory. A few seconds of searching on Google revealed the reason: Raspbian uses 100MB of swap space. In general, when you run an operating system from a SD card, having any amount of swap space is probably a bad idea, because repeatedly writing over the same portion of memory on the SD card will wear it out eventually. These cards were designed for cameras, where you take a picture and save it, then take another picture and save it – repeat 100 times. Then you copy the files to your computer and then you may or may not delete these images. In this mode, the number of write operations to the same location is not very large, even if you use your camera every day. That is different when the card is used to run an operating system. There are constant read and write operations going on, and swap space, when you run low on memory gets probably hit with the bulk of it.

In this case however, we need to increase the amount of swap space available to help the compiler to compile this file.

To do that, we need to edit the file /etc/dphys-swapfile. I use vi to edit text files, but you can of course use any text editor you are familiar with (e.g. nano or emacs):

sudo vi /etc/dphys-swapfile

Now search for this line:

CONF_SWAPSIZE=100

Change the ‘100’ to ‘1024’ and save the file:

CONF_SWAPSIZE=1024

At this point, you can reboot to activate the new setting, or you can run these two commands to reconfigure the virtual memory configuration:

sudo /etc/init.d/dphys-swapfile stop
sudo /etc/init.d/dphys-swapfile start

Now you should be able to build Fldigi successfully.

Once done, it is a good idea to reverse the change in the swap file configuration and go back to CONF_SWAPSIZE=100.

Subscribe to Comments

2 Responses to “Compiling Fldigi 4.1.01 on Raspbian Stretch”

  1. I saw the swap in a recent build hit 128MB. So I set my swap to 256 and will leave it there permanently.

     

    Danny K5CG

  2. Dear Karl,

    Thanks for posting this. A search for Fldigi 4.1 compile error led me to your site.

    I am upgrading from Stretch to Buster and Fldigi 3.x to 4.x and noticed that the compile was failing in the same place each time. My RPi3 would simply lock up and I was at a complete loss on how to solve it. The compiler error message that I got was far less useful than your error message in so much as it just told me that the .o file was not recognised and was truncated. However, following your instructions has allowed a successful compile.

     

    Andy G7OFC

Leave a Reply

Message: