Setting Up a Cross-Compiled Qt Development Environment on Linux for ARM64
Prepare Toolchains and Sources
Obtain a AArch64 cross-compilation toolchain from Linaro:
https://releases.linaro.org/components/toolchain/binaries/7.2-2017.11/aarch64-linux-gnu/
Select gcc-linaro-7.2.1-2017.11-x86_64_aarch64-linux-gnu.tar.xz.
Fetch the full Qt source archive:
http://download.qt.io/archive/qt/5.13/5.13.0/single/qt-everywhere-src-5.13.0.tar.xz
Download the Qt Creator installer package for Linux x64:
http://download.qt.io/archive/qt/5.13/5.13.0/qt-opensource-linux-x64-5.13.0.run
Enstall the AArch64 Toolchain
Move the toolchain archive to /opt and extract it:
cd /opt
sudo tar -xf gcc-linaro-7.2.1-2017.11-x86_64_aarch64-linux-gnu.tar.xz
Rename the extracted directory for brevity:
sudo mv gcc-linaro-7.2.1-2017.11-x86_64_aarch64-linux-gnu gcc-aarch64-linux-gnu
Add its bin directory to the system path:
echo 'export PATH="/opt/gcc-aarch64-linux-gnu/bin:$PATH"' | sudo tee -a /etc/profile
source /etc/profile
Confirm installation:
aarch64-linux-gnu-gcc -v
A version string indicates succsess.
Build Qt Libraries for ARM64
Extract Qt sources into /opt:
cd /opt
tar -xf qt-everywhere-src-5.13.0.tar.xz
cd qt-everywhere-src-5.13.0
Configure platform-specific compiler flags:
sudo nano qtbase/mkspecs/linux-aarch64-gnu-g++/qmake.conf
Append:
QT_QPA_DEFAULT_PLATFORM = linuxfb
QMAKE_CFLAGS_RELEASE += -O2 -march=armv8-a -lts
QMAKE_CXXFLAGS_RELEASE += -O2 -march=armv8-a -lts
Create an automated configure script:
cat > auto_build.sh << 'EOF'
#!/bin/sh
./configure \
-prefix /opt/qt5.13.0-arm \
-confirm-license \
-opensource \
-release \
-make libs \
-xplatform linux-aarch64-gnu-g++ \
-pch \
-qt-libjpeg \
-qt-libpng \
-qt-zlib \
-no-opengl \
-no-sse2 \
-no-openssl \
-no-cups \
-no-glib \
-no-dbus \
-no-xcb \
-no-separate-debug-info
EOF
Set execute permission and run:
sudo chmod +x auto_build.sh
./auto_build.sh
After configuration completes, compile and install:
sudo make -j$(nproc)
sudo make install
The output directory /opt/qt5.13.0-arm will contain the ARM64 Qt build.
Deploy Qt Creator
Run the installer in /opt:
sudo ./qt-opensource-linux-x64-5.13.0.run
Choose only the Tools component during setup.
Launch Qt Creator:
cd /opt/Qt5.13.0/Tools/QtCreator/bin
sudo ./qtcreator
In Tools → Options → Kits:
- Under Compilers, manually register
aarch64-linux-gnu-gccandaarch64-linux-gnu-g++. - In Qt Versions, add the
qmakebinary located at/opt/qt5.13.0-arm/bin/qmake. - Create a new kit associating the ARM64 compiler and Qt version.
Transfer Qt Runtime to Target Board
Package the compiled Qt runtime:
cd /opt
tar -czf qt5.13.0-arm.tar.gz qt5.13.0-arm
Copy qt5.13.0-arm.tar.gz to the target device (e.g., via scp) and extract under /opt:
cd /opt
tar -xzf qt5.13.0-arm.tar.gz
Configure environment variables on the board:
sudo nano /etc/profile
Insert:
export QT_ROOT=/opt/qt5.13.0-arm
export LD_LIBRARY_PATH=$QT_ROOT/lib:$LD_LIBRARY_PATH
export QT_QPA_PLATFORM_PLUGIN_PATH=$QT_ROOT/plugins
export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0
export QT_QPA_FONTDIR=/usr/share/fonts/ttf
Apply changes:
source /etc/profile
Run Applications on Target
Deploy the compiled executable to the board’s filesystem. Launch specifying the framebuffer platform:
./your_app -platform linuxfb