This article was successfully installed under virtual machine conditions, using Ubuntu18.04 64-bit image as the compilation environment.
- Need to prepare materials
- Cross-compiler: use when the target machine is 64-bit
gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu (64-bit cross-compiler).tar.xz
If the target machine is 32-bit:
gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf.tar.xz
② qt5 source code and qtcreator running package (this example is based on a 64-bit machine)
qt-everywhere-src-5.12.11 (QT source code).tar.xz
qt-opensource-linux-x64-5.12.11 (QT development tools).run
- Installation environment (installation in Ubuntu)
The first step is to change the source : (Otherwise it will be so slow that you doubt your life)
sudo you /etc/apt/sources.list
or
sudo gedit /etc/apt/sources.list
Copy the following source into it (the source from the University of Science and Technology of China is the fastest in actual testing, and more people recommend the Alibaba source):
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
Use sudo apt-get update and sudo apt-get upgrade to update the software download source.
The second step is to install the environment dependencies :
$ sudo apt-get install repo git-core gitk git-gui gcc-arm-linux-gnueabihf u-boot-tools
$ sudo apt-get install device-tree-compiler gcc-aarch64-linux-gnu mtools parted
$ sudo apt-get install libudev-dev libusb-1.0-0-dev python-linaro-image-tools
$ sudo apt-get install linaro-image-tools autoconf autotools-dev libsigsegv2 m4
$ sudo apt-get install intltool libdrm-dev curl sed make binutils build-essential gcc
$ sudo apt-get install g++ bash patch gzip bzip2 perl tar cpio python unzip rsync flex
$ sudo apt-get install bc wget libncurses5 libqt4-dev libglib2.0-dev libgtk2.0-dev
$ sudo apt-get install libglade2-dev cvs git mercurial rsync openssh-client subversion
$ sudo apt-get install asciidoc w3m dblatex graphviz python-matplotlib libc6:i386
$ sudo apt-get install libssl-dev texinfo genext2fs
$ sudo apt-get install lib32stdc++6
$ sudo apt-get install g++-arm-linux-gnueabihf
$sudo apt-get install gcc-arm-linux-gnueabihf
$ sudo apt-get install liblz4-tool lib32gcc-7-dev g++-7 libstdc++-7-dev
If it is rk3399, you still need to install it.
sudo apt-get install g++-aarch64-linux-gnu
sudo apt-get install gcc-aarch64-linux-gnu
- Build a cross-compilation environment
The setting of the cross-compilation environment is basically to reduce the pressure to the specified path, and then add the path to the environment variable.
Enter the /opt target: cd opt
Create a new directory to store the cross-compiler: mkdir gcc-arm-6.3.1/
Enter the location where the cross-compiler is stored, and then copy the compiler to gcc-arm-6.3.1/: mv gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf.tar.xz /opt/gcc- arm-6.3.1/
Unzip it under gcc-arm-6.3.1/: cd /opt/gcc-arm-6.3.1/
tar -xvf gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf.tar.xz
Wait for the decompression to complete. After completion, there will be a bin target, which needs to be added to the environment variable.
Open the bashrc file: sudo vi /root/.bashrc or sudo gedit /root/.bashrc
添加:export PATH=/opt/gcc-arm-6.3.1/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin:$PATH
Source it to take effect: sudo source /root/.bashrc
Check whether it takes effect: arm-linux-gnueabihf-g++ -v. If it can be found, it is successful.
- Compile QT
Unzip the source code to the current path. My default is the user directory: /home/jinyh: tar -xvf qt-everywhere-src-5.12.11.tar.xz
The following two steps are critical and require the creation of compilation configuration and qmake configuration.
My compilation configuration is;
./configure -prefix /usr/local/qt-arm/QtEmbedded-6.3.1-arm -confirm-license -opensource -release -make libs -xplatform linux-arm-gnueabi-g++ -pch -qt-libjpeg -qt-libpng -qt-zlib -no-opengl -no-sse2 -no-openssl -no-cups -no-glib -dbus -no-xcb -no-separate-debug-info -no-iconv
It can be run as a script or directly entered as a command.
-prefix /usr/local/qt-arm/QtEmbedded-6.3.1-arm means the installation path of Qt, which needs to be mkdir out in advance.
One thing to note above is the -xplatform parameter. I chose arm-gnueabi-g++ because this platform is included in the directory /home/jinyh/qt-everywhere-src-5.12.11/qtbase/mkspecs. If you want to use your own platform, you need to create a new platform and configuration file here (not tried).
Modify the configuration file, find the qmake.conf file in /home/jinyh/qt-everywhere-src-5.12.11/qtbase/mkspecs/linux-arm-gnueabi-g++, and modify it as follows:
#
# qmake configuration for building with arm-linux-gnueabi-g++
#
MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublib
include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
# modifications to g++.conf
QMAKE_CC =/opt/gcc-arm-6.3.1/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
QMAKE_CXX =/opt/gcc-arm-6.3.1/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++
QMAKE_LINK =/opt/gcc-arm-6.3.1/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++
QMAKE_LINK_SHLIB=/opt/gcc-arm-6.3.1/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++
# modifications to linux.conf
QMAKE_AR =/opt/gcc-arm-6.3.1/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ar cqs
QMAKE_OBJCOPY =/opt/gcc-arm-6.3.1/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-objcopy
QMAKE_NM =/opt/gcc-arm-6.3.1/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-nm -P
QMAKE_STRIP =/opt/gcc-arm-6.3.1/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-strip
load(qt_config)
The main modification above is to use a cross-compiler for compilation.
Run the configuration script or just throw it in and run it. You will probably see a success screen like this.
Then you can happily make -j4 && sudo make install and wait for the installation to complete. If nothing else, it will take about 3 hours.
Configure environment variables:
export QTDIR=/usr/local/qt-arm/QtEmbedded-6.3.1-arm
export PATH=$QTDIR/bin:$PATH
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
Then source it, enter qmake -version , and you can see the version information, OK .
- Install qtcreator
Ubuntu# chmod +x qt-opensource-linux-x64-5.12.2.run
Ubuntu# sudo ./qt-opensource-linux-x64-5.12.2.run
Ubuntu# Cd opt
Mkdir Qt5.12.2
Create the installation directory of qtcreator .
After selecting the installation directory, continue to the next step. The window that appears is to select components. You can choose according to the components you need, but try to select everything except Android . Click Next.
A window asking for the license agreement will appear, select the first item to agree and read the terms. Click Next again. When you are ready for installation, just click Install.
At this point Qt is ready to be installed.
Add environment variables, vi /root/.bashrc,
export PATH="/opt/Qt5.12.11/Tools/QtCreator/bin:$PATH"
export PATH="/opt/Qt5.12.11/5.12.11/gcc_64/bin:$PATH"
source /root/.bashrc, and then enter qtcreator under the user name to start qtcreator.
Or type in the terminal
/opt/Qt5.12.2/5.12.2/QtCreator/bin/qtcreator &
This sentence can be saved, copied and pasted.
- Configure QT compilation component kit
After entering ubuntu, enter sudo su
enter password,
Then, enter qtcreator to open the project. ( There may be a problem here, which will be discussed at the end! )
Find qt's Tools and open Options
Then, Manual, Add G++, just change the gcc in the GCC just now to the g++ one.
In the next step, Qt Versions and qmake will basically be added automatically, if the above programs are correct.
The Kit kit basically configures the compiler and version just now. The exclamation point in front is because the device is not selected, so you can ignore it.
You can generate a 32-bit arm execution program, and then run it on the rk3288 development board.
last question:
After installing Qt5.15.0, an error popped up when running the test case: qt.qpa.plugin: Could not load the Qt platform plugin “xcb” in “” even though it was found. This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb. Aborted (core dumped) According to the problem description, although the Qt platform plugin "xcb" can be found but cannot be loaded ”, although it is said that reinstalling may be able to solve the problem, if possible, it should be considered as the lowest option.
Solution:
$ sudo apt-get install libxcb-xinerama0
See the documentation for details:
Solve the problem of qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in Qt under Ubuntu18.04_Feng Yihangge's blog-CSDN blog Other main references: