Friday, June 2, 2023

How to build WSJT-X from source on macOS

WSJT-X
Compile WSJT-X on Mac.

Works on my spare Late 2014 5K iMac running Big Sur 11.7.10 with Xcode 13.2.1.

Information was passed onto me from AA5SH - Notes on Building WSJT-X on my Mac. The main difference is this guide uses current stable release of Hamlib (4.5.5) from their Github repo.

The steps create a directory called /Users/<username>/wsjtx-build, with a sub-directory each for Hamlib and WSJT-X source code and building.

A detailed guide of how I have my rig control, logging, and digi mode apps configured is at:
https://lonneys-notebook.blogspot.com/2023/06/macloggerdx-flrig-with-wsjt-x-fldigi.html


Xcode


Xcode can be downloaded from the App Store, for older versions of macOS it can be downloaded from https://developer.apple.com/xcode/resources/ > Additional downloads > Search for the version number.

Supported version of Xcode for a given version of macOS see https://en.wikipedia.org/wiki/Xcode.

There are two parts to install Xcode one is just to install from the App Store or download from the Apple developer site, and then also from the command line run the following command:

xcode-select --install

Agree to the Xcode license agreement:

sudo xcodebuild -license


CMake


Download the latest CMake universal from http://www.cmake.org/download/

Open the DMG then drag and drop the application bundle onto the supplied /Applications link.

To complete the install process run:

sudo "/Applications/CMake.app/Contents/MacOS/cmake" --install


Homebrew


Install Homebrew from https://brew.sh/ 

Run the two commands shown at competition to add it to the path.

Install gcc@9:

brew install gcc@9


Mac Ports


Install Mac Ports from https://www.macports.org/

Quit and re-open terminal after installing. 

Install the required ports, answer yes to dependancies or use port -N (non interactive):

sudo port install autoconf
sudo port install automake
sudo port install libtool
sudo port install pkgconfig
sudo port install texinfo
sudo port install fftw-3-single +gcc9
sudo port install asciidoc
sudo port install asciidoctor
sudo port install libusb-devel
sudo port install boost
sudo port install qt5
sudo port install qt5-qtmultimedia
sudo port install qt5-qtwebsockets


Build Hamlib



This only needs to be done once.

Using the current stable release, 4.5.5 at this time.

mkdir -p ~/wsjtx-build/hamlib-prefix/build
cd ~/wsjtx-build/hamlib-prefix
git clone --depth 1 --branch 4.5.5 https://github.com/Hamlib/Hamlib.git src
cd src
./bootstrap
cd ../build

../src/configure \
   --enable-static \
   --disable-shared \
   --disable-winradio \
   --prefix=$HOME/wsjtx-build/hamlib-prefix \
   CFLAGS="-g -O2 -mmacosx-version-min=10.7 -I/opt/local/include" \
   LIBUSB_LIBS="-L/opt/local/lib -lusb-1.0"

make
make install-strip

If make install-strip fails, run make install


Build WSJT-X


Download source code tarball (.tgz) from:



Note: WSJT-X Improved includes additional features (some later make it into regular WSJT-X), and alternate layouts.

Extract the tarball file, you should see a folder named wsjtx-<version number>.

Open the src folder with-in this and extract wsjtx.tgz, this is the source code.

mkdir -p ~/wsjtx-build/wsjtx-prefix/src
mkdir -p ~/wsjtx-build/wsjtx-prefix/build

Copy the source code with in the expanded wsjtx folder into ~/wsjtx-build/wsjtx-prefix/src

cd ~/wsjtx-build/wsjtx-prefix/build

FC=/usr/local/Cellar/gcc@9/9.5.0/bin/gfortran-9 \
   cmake \
   -D CMAKE_PREFIX_PATH="/opt/local/libexec/qt5;~/wsjtx-build/hamlib-prefix;/opt/local" \
   -D CMAKE_INSTALL_PREFIX=~/wsjtx-build/wsjtx-prefix \
   -D CMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/ \
   ~/wsjtx-build/wsjtx-prefix/src

Substitute the Mac OS X SDK version you have installed in the above command if you have a different version.

cmake --build .
cmake --build . --target install # Builds wsjt-x application bundle 
cmake --build . --target package # Builds .dmg file in build directory


Other Info





Misc Notes


Find QT version (installed via Mac Ports): /opt/local/libexec/qt5/bin/qmake -v


Build JS8Call on macOS



Not tried it my self yet.