Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Setting Up a Cross-Compiled Qt Development Environment on Linux for ARM64

Tech 1

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-gcc and aarch64-linux-gnu-g++.
  • In Qt Versions, add the qmake binary 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

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.