Skip to content

Instantly share code, notes, and snippets.

@tresf
Last active May 21, 2024 04:43
Show Gist options
  • Save tresf/b00e4d9c9bbef8423a97e1a6e6178767 to your computer and use it in GitHub Desktop.
Save tresf/b00e4d9c9bbef8423a97e1a6e6178767 to your computer and use it in GitHub Desktop.
Cross-compile LMMS for ARM64

Description

This tutorial was written for Ubuntu 20.04 and is based off of lmms/wiki/Compiling. It adapt well to other Ubuntu verisons or Linux distros, but the package names and sources.list entries will change.

Warning

Warning, this configuration uses ARM64 "port" versions of Ubuntu libraries which cause havoc on apt and the dependency chain. Don't do this on your main machine, or even one you slighlty care about.

Configure modern cmake

sudo snap install cmake --classic
sudo ln -s /snap/bin/cmake /usr/bin/cmake

Configure aarch64 deps

sudo dpkg --add-architecture arm64
sudo nano /etc/apt/sources.list
# aarch64
deb [arch=arm64] http://ports.ubuntu.com/ focal main multiverse universe
deb [arch=arm64] http://ports.ubuntu.com/ focal-security main multiverse universe
deb [arch=arm64] http://ports.ubuntu.com/ focal-backports main multiverse universe
deb [arch=arm64] http://ports.ubuntu.com/ focal-updates main multiverse universe
sudo apt-get update
# x86_64
sudo apt-get install build-essential git perl libxml2-utils libxml-perl g++-10-aarch64-linux-gnu gcc-10-aarch64-linux-gnu
# aarch64
sudo apt-get install libsndfile1-dev:arm64 libfftw3-dev:arm64 libvorbis-dev:arm64 libogg-dev:arm64 \
libmp3lame-dev:arm64 libasound2-dev:arm64 libjack-jackd2-dev:arm64 libsamplerate0-dev:arm64 \
libsdl2-dev:arm64 libstk0-dev:arm64 stk:arm64 libfluidsynth-dev:arm64 portaudio19-dev:arm64 \
libfltk1.3-dev:arm64 libxinerama-dev:arm64 libxft-dev:arm64 libgig-dev:arm64 \
qtbase5-dev:arm64 qtbase5-private-dev:arm64 qttools5-dev-tools:arm64 qttools5-dev:arm64 \
libqt5x11extras5-dev:arm64 libx11-xcb-dev:arm64 libxcb-keysyms1-dev:arm64 libxcb-util0-dev:arm64

Fix broken packages

# Fix broken lrelease
wget http://mirrors.kernel.org/ubuntu/pool/universe/q/qttools-opensource-src/qttools5-dev-tools_5.12.8-0ubuntu1_amd64.deb
sudo dpkg -i qttools5-dev-tools_5.12.8-0ubuntu1_amd64.deb

CMake Toolchain File

set(CMAKE_SYSTEM_NAME Linux)
set(TOOLCHAIN_PREFIX aarch64-linux-gnu)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc-10)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++-10)
set(CMAKE_STRIP ${TOOLCHAIN_PREFIX}-strip CACHE FILEPATH "" FORCE)
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX}/)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)

Prepare source

git clone https://github.com/lmms/lmms --recursive
mkdir lmms/build
cd build

nano ~/lmms/cmake/toolchains/Aarch64.cmake
# paste toolchain contents above

Compile

cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/Aarch64.cmake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment