Skip to content

Linux QT Environment Setup

QT Runtime Environment Test

Ubuntu 20.04

Ubuntu 20.04 comes with QT 5.12.8 runtime environment by default.

1. Check QT libraries

$ ls -l /usr/lib/aarch64-linux-gnu/libQt*

2. Copy the demo to any directory on the system and test:

$ sudo chmod +x ./mainwindow
$ sudo ./mainwindow

Debian 11

Debian 11 comes with QT 5.15.2 runtime environment by default.

1. Check QT libraries

$ ls -l /usr/lib/aarch64-none-linux-gnu/libQt*

2. Copy the demo to any directory on the system and test:

$ sudo chmod +x ./mainwindow
$ sudo ./mainwindow

QT Cross-Compilation Environment Setup

Test platform: Ubuntu 20.04 VM

GCC Cross-Compilation Toolchain

  • SDK Built-in Cross-Compilation Toolchain

Toolchain path (not recommended due to potential version incompatibilities):

(SDK)/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/
  • Install GCC Cross-Compilation Toolchain

Download the GCC cross-compilation toolchain, extract the archive to the VM. -C /opt/gcc-arm specifies the extraction path.

$ sudo tar -xvf gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz -C /opt/gcc-arm
  • Environment Variable Configuration

1. Add the toolchain installation path to environment variables so the system can locate it.

Temporary (current terminal session only):

$ export PATH=/opt/gcc-arm/bin:$PATH

Permanent:

$ sudo vim /etc/profile
export PATH=/opt/gcc-arm/bin:$PATH
source /etc/profile

2. Verify installation

Check if the toolchain is successfully installed and configured:

aarch64-none-linux-gnu-gcc --version

Successful installation shows output similar to:

aarch64-none-linux-gnu-gcc (GNU Toolchain for the A-profile Architecture) 9.2.1 20191203
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

qmake Installation

In Qt projects, qmake generates Makefiles from .pro project files. To install QT on the development board, install GCC and the source code directly without modifying compilation tools.

1. Download Qt / Or download the latest Qt from the official website (Historical versions: Qt Downloads)

Official website download steps:

2. Install required dependencies and toolchain

$ sudo apt-get install build-essential perl python3 git
$ sudo apt-get install '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev
$ sudo apt-get install flex bison gperf libicu-dev libxslt-dev ruby
$ sudo apt-get install libxcursor-dev libxcomposite-dev libxdamage-dev libxrandr-dev libxtst-dev libxss-dev libdbus-1-dev libevent-dev libfontconfig1-dev libcap-dev libpulse-dev libudev-dev libpci-dev libnss3-dev libasound2-dev libegl1-mesa-dev gperf bison nodejs
$ sudo apt-get install libasound2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev 
$ sudo apt-get install libgstreamer-plugins-bad1.0-dev
$ sudo apt install clang libclang-dev
$ sudo apt-get install xz-utils
$ sudo ln -s /usr/bin/python3 /usr/bin/python

3. Extract the downloaded Qt to the /opt folder

$ sudo tar -xvf qt-everywhere-src-5.12.2.tar.xz -C /opt/

Enter the extracted folder and create an auto.sh script file

$ sudo vim auto.sh
#!/bin/bash

./configure \
    -prefix /opt/Qt/ \
    -opensource -confirm-license \
    -nomake examples \
    -nomake tests \
    -release \
    -xplatform linux-aarch64-gnu-g++ \
    -device-option CROSS_COMPILE=/opt/gcc-arm/bin/aarch64-none-linux-gnu- \
    -no-eglfs \
    -no-xcb \
    -no-opengl \
    -skip qt3d \
    -skip qtcharts \
    -skip qtandroidextras \
    -skip qtlocation \
    -skip qtmultimedia \
    -skip qtsensors \
    -skip qtserialbus \
    -skip qtserialport \
    -skip qtwayland \
    -skip qtdeclarative \
    -skip qtxmlpatterns \
    -skip qtwebchannel \
    -skip qtwebengine \

4. Modify the qmake.conf file

Note

The qtbase/mkspecs/ directory in the Qt source contains configurations for different platforms. This example uses the qmake configuration in the linux-aarch64-gnu-g++ directory. Since the cross-compilation toolchain differs, modify qmake.conf to adapt to the cross-compilation tool in use.

# modifications to g++.conf
QMAKE_CC                =/opt/gcc-arm/bin/aarch64-none-linux-gnu-gcc
QMAKE_CXX               =/opt/gcc-arm/bin/aarch64-none-linux-gnu-g++
QMAKE_LINK              =/opt/gcc-arm/bin/aarch64-none-linux-gnu-g++
QMAKE_LINK_SHLIB        =/opt/gcc-arm/bin/aarch64-none-linux-gnu-g++

# modifications to linux.conf
QMAKE_AR                =/opt/gcc-arm/bin/aarch64-none-linux-gnu-ar cqs
QMAKE_OBJCOPY           =/opt/gcc-arm/bin/aarch64-none-linux-gnu-objcopy
QMAKE_NM                =/opt/gcc-arm/bin/aarch64-none-linux-gnu-nm -P
QMAKE_STRIP             =/opt/gcc-arm/bin/aarch64-none-linux-gnu-strip

5. Run the script to cross-configure Qt source, execute ./configure

$ sudo chmod 755 auto.sh
$ sudo ./auto.sh

Note

./configure options:
-prefix /opt/Qt/: Qt installation path
-opensource -confirm-license: Install Qt open-source edition
-nomake examples: Skip building Qt example programs
-nomake tests: Skip building Qt test cases and framework
-release: Build Qt in Release mode
-xplatform: Specify the target platform for Qt compilation
-qtlocation: Full cross-platform location service solution
-qtwebengine: High-performance web rendering engine based on Chromium
-skip: Skip compiling specified Qt modules
If location services or web rendering features are not needed, use -skip to exclude qtlocation and qtwebengine modules. This significantly reduces compilation time.

  1. Run compilation. Compilation takes approximately 4-12 hours.
$ sudo make -j4

After compilation completes, run the following command to install the program to the path specified by -prefix (/opt/Qt/).

$ sudo make install

7. After successful installation, modify environment variables

$ sudo vim /etc/profile
export QTDIR=/opt/Qt
export PATH=$QTDIR/bin:$PATH
export MANPATH=$QTDIR/man:$MANPATH
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
$ source /etc/profile

8. Check version

$ qmake -v

qtcreator Installation

Tip

Installing qtcreator requires Qt to be installed first. Various installation methods are available. Choose the appropriate one for your situation.

Install via Package

Tip

Install qtcreator in the VM.

1. Go to the Qt official website and select the installation package.

image-20250219155414011

2. Run the installer in the VM

Tip

A Qt account registration is required. The installation process is graphical, similar to Windows installation.

chmod +x qt-opensource-linux-x64-5.12.2.run
./qt-opensource-linux-x64-5.12.2.run

Install via apt

Tip

Install qtcreator directly on the development board.

Installing qtcreator via apt may result in a version mismatch with the installed Qt.

sudo apt update
sudo apt install qtcreator

Install from Source

Tip

Install qtcreator in the VM. Only use this method if a specific version of Qt Creator is required (not recommended). Use a Qt Creator version that matches your Qt framework version.

1. Download Qt Creator source code

image-20241028094210629

2. Extract the archive, enter the extracted directory, and run:

$ qmake -r

3. After the above command generates the Makefile, run the compilation:

$ sudo make -j4

4. After compilation completes, run:

$ sudo make install

5. The bin directory contains qtcreator and qtcreator.sh. Run the following command to start qtcreator in the background, then configure qtcreator as needed.

$ ./qtcreator.sh &

Kit Configuration

1. Add C Compiler and C++ Compiler in GCC settings

image-20250416112806987

2. Add qmake

image-20250416112845224

3. Configuration complete

image-20250416112945015