ARM64 Cross-Compiler Environment Setup
Demo overview
QT executables compiled on the PC are x86-architecture and cannot run on an ARM-architecture development board. You need to set up a cross-compilation environment on the PC to produce ARM-architecture executables.
PC environment:
- PC system: Ubuntu 20.04 (x86_64) (both the VMware and Ubuntu image files are under 05-Development Materials\03-QT Development Materials)
- Qt version: Qt 5.12.9 (GCC 9.4.0, 64-bit)
- Cross-compiler: aarch64-linux-gnu-gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Cross-compilation
First, install the cross-compiler on Ubuntu.
sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
#查看是否安装,版本号--9.4.0
aarch64-linux-gnu-gcc --versionCopy the qt-everywhere-src-5.12.9.tar archive from the 05-Development Materials\03-QT Development Materials directory to the Ubuntu home directory and extract it.
tar -xvf qt-everywhere-src-5.12.9.tarOpen qt-everywhere-src-5.12.8/qtbase/mkspecs/linux-aarch64-gnu-g++/qmake.conf and change the compiler path in the red box to the path of the compiler you just downloaded (sudo apt install gcc-aarch64-linux-gnu) — when installed via apt it is usually under /usr/bin. Save the file after editing.

In the home directory, right-click and create two directories: "Qt-5.12.9-build" and "Qt-5.12.9-arm64".
Enter the Qt-5.12.9-build directory and run the following command to generate the Makefile.
./../qt-everywhere-src-5.12.9/configure -prefix /home/ubuntu/Qt-5.12.9-arm64 -make libs -xplatform linux-aarch64-gnu-g++ -skip qtdeclarative -no-opengl
If you get the error shown above, run:
sudo apt update
sudo apt install build-essentialDuring the process there are two prompts; enter "o" and "y" respectively. When finished, you can see that a Makefile has been generated in this directory.

Continue in the Qt-5.12.9-build directory and run the following command to start compiling (about 10 minutes).
make -j4 2>&1 | tee build.logAfter compilation finishes, continue in the Qt-5.12.9-build directory and run:
make installWhen finished, open the Qt-5.12.9-arm64 directory; qmake is in the bin subdirectory.

Install and configure the environment
Copy the qt-opensource-linux-x64-5.12.9.run file from the 05-Development Materials\03-QT Development Materials directory to the Ubuntu home directory. In the terminal, navigate to the home directory and run the following command to open the installer.
chmod +x qt-opensource-linux-x64-5.12.9.run
./ qt-opensource-linux-x64-5.12.9.runIf you are asked to log in to an account, you can disconnect from the network and exit, then re-run the command above — you can then install without logging in. Follow the installer to select the installation configuration as needed.

After installation, open Qt and configure the environment with the following steps.

Click Add for GCC-C / GCC-C++ and add the aarch64-linux-gnu-gcc and aarch64-linux-gnu-g++ cross-compilers you just downloaded (when installed with sudo they are usually under /usr/bin).

Click Qt-Version, click Add, and add the qmake file you just built (inside bin), giving it a version name. Warnings can be ignored.

Click Kit, enter any name, select the compilers you just added for C and C++, and select the Qt version added in the previous step for Qt version.

Create a new project and select the configured build environment.

Build the project to obtain an ARM-architecture executable. The RK3568 already has a QT environment deployed — just copy the executable to the board, change its permissions, and run it in the terminal, or double-click it with the mouse to open it.
