21 Mar 2019

Compiling Fldigi on macOS using Xcode 9.2

Posted by khk

I’ve been using Fldigi 4.0.x for quite some time on my Mac. To install it, I always just downloaded the DMG file and dragged the APP bundle into my Applications folder. When version 4.1 came out, the did no longer work: I am still running macOS 10.12.6, and the new version of Fldigi is no longer available in a 64bit version for older versions of macOS, so I had to download the 32bit version. And that did not run on my system: It always crashed a few seconds after starting it. So, I happily went back to 4.0.18. That is, until David (W1HKJ) posted a survey a few days ago about which Fldigi version people were using on macOS. After explaining my situation, David suggested that I should build from sources instead of downloading the precompiled application.

There is an excellent document available that describes how to build Fldigi on macOS, using Xcode 8: http://www.w1hkj.com/doku/doku.php?id=howto:building_on_os_x – I am using Xcode 9.2 so I should not have been too surprised when I ran into a few problems. After digging through some Google search results, I was able to figure out a workaround for all problems, and ended up with a working version of Fldigi 4.1.01.

If you want to build on Xcode 9, just follow along the instructions, until you run into a problem, then come back here to see how to get around it.

libsamplerate-0.1.9

When you build libsamplerate, it will fail while building one of the examples:

CC       audio_out.o
audio_out.c:435:10: fatal error: 'Carbon.h' file not found
#include 
         ^~~~~~~~~~
1 error generated.
Makefile:469: recipe for target 'audio_out.o' failed
make[1]: *** [audio_out.o] Error 1

We can fix that by changing the path of the included file from to <Carbon/Carbon.h>: Edit the file examples/audio_out.c and search for the include statement from the error message (it’s in line #435), and then change it from
#include 

to
#include &lt;Carbon/Carbon.h&gt;

Now run “make” again, and the build will finish.

portaudio

The next error message is a bit more complex:

libtool: compile:  gcc -c -std=c99 -O2 -Wall -pedantic -pipe -fPIC -DNDEBUG -DPA_LITTLE_ENDIAN -I./include -I./src/common -I./src/os/unix -Werror -arch i386 -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.4 -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DSIZEOF_SHORT=2 -DSIZEOF_INT=4 -DSIZEOF_LONG=8 -DHAVE_CLOCK_GETTIME=1 -DHAVE_NANOSLEEP=1 -DPA_USE_COREAUDIO=1 src/hostapi/coreaudio/pa_mac_core.c  -fno-common -DPIC -o src/hostapi/coreaudio/.libs/pa_mac_core.o
In file included from src/hostapi/coreaudio/pa_mac_core.c:65:
In file included from src/hostapi/coreaudio/pa_mac_core_internal.h:64:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/CoreAudio.h:19:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardware.h:83:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/include/float.h:36:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk/usr/include/float.h:8:15: fatal error: 'float.h' file not found
#include_next 
              ^~~~~~~~~
1 error generated.
Makefile:227: recipe for target 'src/hostapi/coreaudio/pa_mac_core.lo' failed

What it comes down to is that a file that should be easy to find is not where the compiler expects it to be. We can fix that by setting an environment variable before we run “make”:
export CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include

When we now run “make” again, it will get us to the next string of error messages – and I am not showing all of them, just the last few lines. They all look similar and are related.
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/stdio.h:235:18: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)
      [-Werror,-Wnullability-completeness]
int      fflush(FILE *);
                     ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/stdio.h:235:18: note: insert '_Nullable' if the pointer may be null
int      fflush(FILE *);
                     ^
                      _Nullable
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/stdio.h:235:18: note: insert '_Nonnull' if the pointer should never be null
int      fflush(FILE *);
                     ^
                      _Nonnull
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
Makefile:227: recipe for target 'src/common/pa_debugprint.lo' failed

This one requires that we edit the file “Makefile”. Open it up in an ASCII editor and search for a line that starts with “CFLAGS = ” – it will contain the command line argument “-pedantic”. We have to replace this “-pedantic” with “-Wno-nullability-completeness”. Once this is done, I would recommend to first run a “make clean” followed by a “make”:
make clean
make

Now just finish the build instructions, and you should end up with a working copy of Fldigi.

Leave a Reply

Message: