Skip to content

Building Golden Cheetah on Raspberry Pi

Matthew Lewis edited this page Oct 9, 2023 · 19 revisions

Below are instructions to create a base install of GC on a clean install of Raspberry Pi OS Buster and Bullseye using QT5. You can download the latest version of Raspberry Pi OS from the Raspberry Pi Website. This walk-through assumes the user has successfully installed a fresh version of Raspberry Pi OS Bullseye (Installing OS images on Raspberry Pi).

Since this is a rather time consuming and error prone process, we have created a Makefile that captures all the steps described here for building GoldenCheetah v3.5 on Raspberry Pi OS Buster only. IMPORTANT NOTE: This Makefile only works for GoldenCheetah V3.5. Instructions for compiling GoldenCheetah V3.6 on Raspberry Pi OS Bullseye are provided here.

If you configure a swapfile you can get the code to compile and run on a Raspberry Pi 3B+, but it is pretty slow and you are almost out of memory just starting the app.

There are cues in the walk-through where you need to take action to include ANT+ and Strava support.

Status of environments, OS, and GC version combinations that have been tested

Raspberry Pi 4B 2GB, Raspberry Pi OS Buster (2019-09-26) normal version (not full or lite), GC 3.5 RC2
Raspberry Pi 4B 2GB, Raspberry Pi OS Buster (2019-09-26) normal version (not full or lite), GC 3.5 RC2
Raspberry Pi 3B+ 1 GB, Raspberry Pi OS Buster, GC 3.5. (Run in console-mode, 16 MB GPU-ram and make -j1', pg memory), working with VLC-video also
Raspberry Pi 4B 8GB, Raspberry Pi OS Bullseye 64-bit, GC 3.6 - successfully tested with Wahoo Kickr (ANT+ and Bluetooth), Garmin cadence sensor (ANT+), Garmin HRM (ANT+) and Polar HRM (Bluetooth)
Raspberry Pi CM4 8GB, Raspberry Pi OS Bullseye 32-bit, GC 3.6 (compilation only)

1. Update the Raspberry Pi’s Software

$ sudo apt update  {if you not run yet updated, it may fail saying library date is in future, just run it again}
$ sudo apt -y full-upgrade --autoremove
$ sudo apt -y autoclean
$ sudo reboot

2. Install QT5 and necessary libraries (Raspberry Pi OS Bullseye)

$ sudo apt-get -y install build-essential cmake bison flex gperf automake libtool
$ sudo apt-get -y install libglu1-mesa-dev libgles2-mesa-dev libgbm-dev libdrm-dev libgsl-dev libusb-dev libusb-1.0-0-dev libical-dev libvlc-dev libvlccore-dev
$ sudo apt-get -y install libfontconfig1-dev libdbus-1-dev libfreetype6-dev libicu-dev icu-devtools libudev-dev libinput-dev libxkbcommon-dev libssl-dev libpng-dev libjpeg-dev libglib2.0-dev libsqlite3-dev libraspberrypi-dev
$ sudo apt-get -y install libxtst-dev libpulse-dev libasound2-dev libxrandr-dev libxcb1-dev libxcb1 libxcb-xkb-dev libx11-xcb-dev libkml-dev
$ sudo apt-get -y install qtbase5-dev qtbase5-dev-tools qt5-qmake qtchooser qtcreator qtcreator-data libqt5svg5-dev libqt5serialport5-dev libqt5charts5-dev qtmultimedia5-dev qtconnectivity5-dev libqt5webkit5-dev qtbase5-private-dev libqt5webchannel5-dev libqt5webchannel5 qtpositioning5-dev
$ sudo apt-get -y install sip-dev r-base python3-pip bluez libbluetooth-dev libre2-dev libnss3-dev python2 nodejs
$ sudo apt-get -y install libdrm-dev libxdamage-dev libxkbfile-dev libxml2-dev libxslt1-dev libminizip-dev libjsoncpp-dev liblcms2-dev libevent-dev libprotobuf-dev protobuf-compiler libwebp-dev libpoppler-cpp-dev ninja-build re2c libopus-dev libvpx-dev libxcb-dri3-dev libxcomposite-dev libharfbuzz-dev libsnappy-dev libxcursor-dev libxi-dev libavcodec-dev
$ sudo apt-get -y install qml-module-qtquick-privatewidgets qml-module-qtquick2 qml-module-qtquick-xmllistmodel qml-module-qtquick-controls qml-module-qtquick-controls2 libqt5quick5 libqt5quickwidgets5 qml-module-qtwebkit libqt5quicktest5 libqt5quickwidgets5 qml-module-qtmultimedia qtdeclarative5-dev qtdeclarative5-dev-tools qtdeclarative5-private-dev

2.1 FTDI D2XX library (if required)

32-bit:

$ wget https://ftdichip.com/wp-content/uploads/2022/07/libftd2xx-arm-v7-hf-1.4.27.tgz
$ mkdir -p libftd2xx-arm-v7-hf-1.4.27 && tar zxf libftd2xx-arm-v7-hf-1.4.27.tgz --directory libftd2xx-arm-v7-hf-1.4.27 --strip-components=1
$ cd libftd2xx-arm-v7-hf-1.4.27
$ sudo cp build/libftd2xx.a build/libftd2xx.so.1.4.27 /usr/local/lib/.
$ sudo ln -sf /usr/local/lib/libftd2xx.so.1.4.27 /usr/local/lib/libftd2xx.so
$ sudo cp ftd2xx.h /usr/local/include/.

On 64-bit change `arm-v7-hf` to `arm-v8`.

2.2 SRMIO library (if required)

$ git clone https://github.com/rclasen/srmio
$ cd srmio
$ sh ./genautomake.sh
$ ./configure
$ make
$ sudo make install

2.3 QT WebEngine

Unfortunately Raspberry Pi OS does not include the QT5 WebEngine modules. Building is very complicated and time consuming – the instructions provided below are based on this article. The dependencies should already have been install in the steps above.

This compile takes about a day on a Pi4/CM4 with 8GB RAM – the 4 parallel build jobs ensures that all cores are used. Even with 8GB RAM the build will fail when compiling at various points with 4 parallel build jobs due to running out of memory. When you hit this, simply run with `make -j1 NINJAJOBS=-j1`.

$ wget https://download.qt.io/official_releases/qt/5.15/5.15.2/submodules/qtwebengine-everywhere-src-5.15.2.tar.xz
$ tar xf qtwebengine-everywhere-src-5.15.2.tar.xz
$ cd qtwebengine-everywhere-src-5.15.2
$ mkdir build
$ cd build
$ qmake .. -- -no-webengine-geolocation
$ make -j4 NINJAJOBS=-j4
$ make install

The build might fail on Raspberry Pi OS Bullseye 64-bit with the following error:

...: relocation truncated to fit: R_AARCH64_CONDBR19 against symbol 'ff_prefetch_aarch64' defined in .text section in .../ffmpeg_internal/videodsp.o

This bug is described in more detail here. Very complicated, but one workaround is to change the assembler code in videodsp.S to:

      add       x0,  x0,  x1,  lsl #1
      b.le      1f
      b         X(ff_prefetch_aarch64)
   1:
      ret

3. Add ANT+ stick support {not necessary if you do not plan to use an ANT+ stick/devices}

To allow GC to write to the USB device you need to create the following file {as root}: `/etc/udev/rules.d/52-garmin-usb.rules`
Add the following six lines to the file. After saving the file I recommend you exit and then reboot.

# Garmin ANT+ – USB1
ATTRS{idVendor}==”0fcf”, ATTRS{idProduct}==”1004″, MODE=”0666″
# Garmin ANT+ – USB2
ATTRS{idVendor}==”0fcf”, ATTRS{idProduct}==”1008″, MODE=”0666″
# hLine USB2 ANT2
ATTRS{idVendor}==”0fcf”, ATTRS{idProduct}==”1009″, MODE=”0666″

4. Download GoldenCheetah and configure

$ cd
$ mkdir -p projects
$ cd projects
$ git clone https://github.com/GoldenCheetah/GoldenCheetah.git
$ cd GoldenCheetah
$ git switch --detach v3.6
$ cp qwt/qwtconfig.pri.in qwt/qwtconfig.pri
$ cd src
$ cp gcconfig.pri.in gcconfig.pri
$ nano gcconfig.pri
    > Uncomment line (remove the leading '#' character): #CONFIG += release
    > Uncomment line: #GSL_INCLUDES = /usr/include
    > Uncomment line: #GSL_LIBS = -lgsl -lgslcblas -lm
    > Uncomment line: #QMAKE_LRELEASE = /usr/bin/lrelease
    > Uncomment line: #QMAKE_CXXFLAGS += -03
    > Uncomment line: #QMAKE_LEX  = flex
    > Uncomment line: #QMAKE_YACC = bison
    > Uncomment line: #QMAKE_MOVE = cp
    > Uncomment line: #KML_INSTALL = /usr/local
    > Change the value to: KML_INSTALL = /usr
    > Uncomment line: #BOOST_INCLUDE = /usr/include
    > Uncomment line: #ICAL_INSTALL =
    > Change the value to: ICAL_INSTALL = /usr/lib
    > Uncomment line: #LIBUSB_INSTALL = /usr/local
    > Change the value to: LIBUSB_INSTALL = /usr/lib
    > Uncomment line: #LIBUSB_USE_V_1
    > Uncomment line: #LIBZ_LIBS += -lz

Strava support:

If you want to sync with Strava, you will need to add custom lines to the gcconfig.pri file prior to compiling. See the Strava configuration page for details.

Python support:

  > Uncomment line: #DEFINES += GC_WANT_PYTHON
  > Uncomment line: #PYTHONINCLUDES += -I/usr/include/python3.6
  > Change the value to: PYTHONINCLUDES = -I/usr/include/python3.9
  > Uncomment the line: #PYTHONLIBS = -L/usr/lib/python3.6/config-3.6m_x86_64-linux-gnu -lpython3.6m
  > (32-bit) Change the value to: PYTHONLIBS = -L/usr/lib/python3.9/config-3.9-arm-linux-gnueabihf -lpython3.9
  > (64-bit) Change the value to: PYTHONLIBS = -L/usr/lib/python3.9/config-3.9-aarch64-linux-gnu -lpython3.9

FTDI D2XX support:

  > Add line: D2XX = /usr/local
  > Add line: D2XX_INSTALL = /usr/local

SRMIO support:

  > Uncomment line: #SRMIO_INSTALL =
  > Change value to: SRMIO_INSTALL = /usr/local

To enable VLC-video:

  > Uncomment line: #VLC_INSTALL
  > Change the value to: VLC_INSTALL = /usr
  > Uncomment line: #VLC_LIBS = -lvlc
  > Comment out the line: DEFINES += GC_VIDEO_NONE
  > Uncomment line: #DEFINES += GC_VIDEO_VLC

R support:

  > Uncomment line: #DEFINES += GC_WANT_R

Note comparing gcconfig.pri and gcconfig.pri.in using diff outputs the following:

$ diff gcconfig.pri gcconfig.pri.in
9c9
< CONFIG += release
---
> #CONFIG += release
15,16c15,16
< GSL_INCLUDES = /usr/include
< GSL_LIBS = -lgsl -lgslcblas -lm
---
> #GSL_INCLUDES = /usr/include
> #GSL_LIBS = -lgsl -lgslcblas -lm
26c26
< DEFINES += GC_WANT_R
---
> #DEFINES += GC_WANT_R
35,36c35,36
< DEFINES += GC_WANT_PYTHON
< PYTHONINCLUDES = -I/usr/include/python3.9
---
> #DEFINES += GC_WANT_PYTHON
> #PYTHONINCLUDES = -I/usr/include/python3.6
38d37
< PYTHONLIBS = -L/usr/lib/python3.9/config-3.9-arm-linux-gnueabihf -lpython3.9
68c67
< QMAKE_LRELEASE = /usr/bin/lrelease
---
> #QMAKE_LRELEASE = /usr/bin/lrelease
75c74
< QMAKE_CXXFLAGS += -O3
---
> #QMAKE_CXXFLAGS += -O3
79,80c78,79
< QMAKE_LEX  = flex
< QMAKE_YACC = bison
---
> #QMAKE_LEX  = flex
> #QMAKE_YACC = bison
82c81
< QMAKE_MOVE = cp
---
> #QMAKE_MOVE = cp
101c100
< SRMIO_INSTALL = /usr/local
---
> #SRMIO_INSTALL =
110,111d108
< D2XX = /usr/local
< D2XX_INSTALL = /usr/local
127c123
< KML_INSTALL = /usr
---
> #KML_INSTALL = /usr/local
133c129
< BOOST_INCLUDE = /usr/include
---
> #BOOST_INCLUDE = /usr/include
149c145
< ICAL_INSTALL = /usr/lib
---
> #ICAL_INSTALL = /usr/local/libical
174d169
< LIBUSB_INSTALL = /usr/lib
177c172
< LIBUSB_USE_V_1 = true # don't use on Windows
---
> #LIBUSB_USE_V_1 = true # don't use on Windows
189d183
< VLC_INSTALL = /usr
195c189
< VLC_LIBS    = -lvlc
---
> # VLC_LIBS    = -lvlc
226,227c220,221
< LIBZ_LIBS    = -lz
---
> #LIBZ_LIBS    = -lz
268c262
< #DEFINES += GC_VIDEO_NONE             # dont add any video playback support
---
> DEFINES += GC_VIDEO_NONE             # dont add any video playback support
271c265
< DEFINES += GC_VIDEO_VLC             # use VideoLan library needs VLC_INSTALL defined above
---
> #DEFINES += GC_VIDEO_VLC             # use VideoLan library needs VLC_INSTALL defined above
281,283d274
<
< DEFINES += GC_STRAVA_CLIENT_ID=\\\"xxxx\\\"
< DEFINES += GC_STRAVA_CLIENT_SECRET=\\\"xxxxxxxxxxxxxxxxxx\\\"

5. Compile GC

$ cd ~/projects/GoldenCheetah
$ sip -c src/Python/SIP src/Python/SIP/goldencheetah.sip
$ qmake -recursive  {if you see translation language and missing file errors, ignore them}
$ make

On Raspberry Pi OS Bullseye and GC versions prior to v3.6 the build will fail reporting that it cannot find DataFilter.tab.h. To fix run the following commands:

$ cp src/DataFilter_yacc.h src/DataFilter.tab.h
$ cp src/JsonRideFile_yacc.h src/JsonRideFile.tab.h
$ cp src/RideDB_yacc.h src/RideDB.tab.h
$ make

Now just sit back and wait. Should take about 1.5 hours with a good heat sink on a Pi4 with 2GB RAM.
When it is all done you will have a GoldenCheetah executable file in your projects/GoldenCheetah/src directory. You can copy it wherever you like, if you want to run it from the command line here just type:

$ ~/projects/GoldenCheetah/src/GoldenCheetah

Install it in /usr/local:

$ sudo cp ~/projects/GoldenCheetah/src/GoldenCheetah /usr/local/bin

Make a Raspbian desktop icon {optional}

$ sudo mkdir -p /usr/local/share/images
$ sudo wget http://www.goldencheetah.org/img/logo.png -O /usr/local/share/images/GoldenCheetah.png
$ cd ~/Desktop
$ nano GoldenCheetah.desktop

Add (copy/paste) the following lines to the file and exit and save the file.

[Desktop Entry]
Name=GoldenCheetah
Comment=Built for suffering
Icon=/usr/local/share/images/GoldenCheetah.png
Exec=/usr/local/bin/GoldenCheetah
Type=Application
Encoding=UTF-8
Terminal=false
Categories=None;
StartupNotify=true

Every time you use the desktop icon it will ask if you want to execute it – select execute. You can disable this in Raspberry Pi OS config files, but that is beyond the scope of this document. A simple but possibly insecure solution is to disable the prompt for all desktop applications – go to File Manager, Edit / Preferences menu and enable “Don’t ask options on launch executable file”.


Updating GoldenCheetah on the Raspberry Pi

Before you compile, make sure you update the software/libraries on the Pi. You can do this by re-performing step 1 from the instructions above. Then:

$ cd ~/projects/GoldenCheetah
$ git pull
$ make clean
$ qmake -recursive
$ make
$ sudo cp src/GoldenCheetah /usr/local/bin/.

Notes

  • I highly advise disabling the screen saver on your Raspberry Pi.
  • Troubles with ANT+ or BTLE> ANT and BTLE Troubleshooting
  • To install Strava sync you need to create your own API keys and add to the gcconfig.pri file. See Strava Sync for GC.

Clone this wiki locally