Configure the Qt5.4.2 cross-compilation environment of the virtual machine x86_64 (Ubuntu 20.04) and Jetson nano ARM64 (Ubuntu 18.04). The specific hardware environment is as follows:
VMware virtual machine (X86_64)
Jetson nano (aarch64)
process main reference:
Ubuntu20.04.1 (X86_64) Qt5.14.2 configuration ARM64 cross-compilation environment
JetsonNano QT5.12.9 cross-compilation and environment construction
1. Cross-compilation environment configuration:
1.1 Install Qt 5.14.2 on the virtual machine (it is more recommended to perform sections 1.2 and 1.3 before installing Qt)
- Execute the .run program directly, and the program will download
the file by itself. The download address
will appear on the interface for installation. The location is as follows, and you can choose by yourself:
if you are not sure what you need, install all the components. After the installation is complete, Qt can be started normally.
Check the installation path: you can see that only gcc_64
1.2 Install the ARM64 compiler and build a Jetson nano cross-compilation environment
Reference:
ubuntu16.04 install cross compilation tool aarch64-linux-gnu-gcc/g++
NVIDIA Jetson NX cross compilation environment Ubuntu18.04
- First check the system version and editor version of Jetson nano: gcc / g++ --version or gcc / g++ -v,
it can be seen that it is ubuntu 18.04 and aarch64-linux-gnu
It has been confirmed that the crossover can be successfully established on Ubuntu18.04 and 20.04 Compiler Environment
1.2.1 Install aarch64 version gcc and g++ on Ubuntu
gcc is the GUN C Compiler ( C compiler ) in GCC . g++ is the GUN C++ Compiler ( C++ compiler ) in GCC Reference: Ubuntu cross-compilation aarch64 version qt
sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
The installation is as follows: check the version
after the installation is complete :
aarch64-linux-gnu-gcc -v
You can also enter aarch64 +TAB to check whether the configuration is successful :
1.2.2 Cross-compilation test of aarch64 version gcc and g++ in Ubuntu
Write a simple demo test
- In the virtual machine:
/*
* test.cpp
* for cplusplus
* test aarch64-linux-gnu-g++
*/
# include<iostream>
int main(int argc,char **argv)
{
std::cout << "hello world!" <<std::endl;
return 0;
}
Compile in a virtual machine :
aarch64-linux-gnu-g++ test.cpp -o test
Obviously, it cannot be executed here, and then put the generated executable file on the embedded board to run. If the permissions are not enough, remember to add permissions
The cross-compilation environment configuration in the Jetson nano development board is successful! ! ! , you can view the file type as follows, it is an ARM executable file
1.3 Compile the Qt source code (compile the corresponding arm64 platform tool chain)
Solution: Because Jetson nano has less resources, configure the ARM64 compilation environment on your own PC, configure the Qt cross-compilation environment, and then use Qt to compile the code you wrote. After compiling on the PC, copy it to run on the ARM platform
1.3.1 qt-everywhere-src-5.14.2.tar.xz Qt source code
Source code compressed file download address
Then decompress the compressed package 1 to get folder 2.
1.3.2 Modify the compilation configuration file
Reference:
Ubuntu cross-compilation aarch64 version qt
JetsonNano QT5.12.9 cross-compilation and environment construction
- Modify the qmake.conf file located in the source code
location:qt-everywhere-src-5.14.2/qtbase/mkspecs/linux-aarch64-gnu-g++/qmake.conf
- The content of the file is as follows:
The tool in the red box above needs to be consistent with your own cross-compilation tool, otherwise the compilation will fail.
Add the following content and modify it: Why do you change it like this? I will study it later**qmake.conf**
. For the parameter function, refer to Qt5.12.11 cross-compilation +64-bit ARM_aarch64+Allwinner H5 CortexA53
QT_QPA_DEFAULT_PLATFORM = linuxfb
QMAKE_CFLAGS_RELEASE += -O2 -march=armv8-a -lts
QMAKE_CXXFLAGS_RELEASE += -O2 -march=armv8-a -lts
The modification is as follows (Jetson-nano is armv8 architecture):
1.3.3 Start compiling (the configuration in this section is temporarily wrong, and the configuration has not been successful, directly see 1.3.4)
Enter the source code directory cd qt-everywhere-src-5.14.2
, create the file autoConfigure.sh to configure the compilation options
cd qt-everywhere-src-5.12.9/
touch autoConfigure.sh
chmod 777 autoConfigure.sh
The content is as follows:
#!/bin/sh
./configure \
-prefix /home/feiyangqu/myFile/Qt/Qt5.14.2-aarch64 \
-confirm-license \
-opensource \
-release \
-make libs \
-xplatform linux-aarch64-gnu-g++ \
-pch \
-qt-libjpeg \
-qt-libpng \
-qt-zlib \
-no-sse2 \
-no-cups \
-no-glib \
-no-dbus \
-no-opengl \
-no-xcb \
-no-separate-debug-info \
- Run directly in the source code directory, that is, the directory where the autoConfigure.sh file is located
./autoConfigure.sh
, and then compile the problems I encountered and solve them: - Encountered a problem:
You don't seem to have 'make' or 'gmake' in your PATH.
Cannot proceed.
Solution: Install the build componentssudo apt-get install build-essential
to run successfully
- Then make again, an error occurs: Project ERROR: Building QtQml requires Python.
Reference: Python and building qtqml requires python cannot be found when building Qt from source code. The solution is as follows:
1.3.4 Start compiling (please read this section before compiling!!! Check the errors you encounter in advance)
There were many errors in the previous operation ./autoConfigure.sh
, so the terminal directly used the following statement and then make
:
- First install the library: refer to compile Qt source code in linux environment
sudo apt-get install build-essential
sudo apt-get install libgl1-mesa-dev
sudo apt-get install libglu1-mesa-dev
sudo apt-get install libegl1-mesa-dev
sudo apt-get install freeglut3-dev
sudo apt-get install libclang-dev
- Then the terminal enters the source code folder and runs the following command to configure
./configure -prefix /home/feiyangq/myFile/Qt/Qt5.14.2-aarch64 -make libs -xplatform linux-aarch64-gnu-g++ -no-opengl -skip qtdeclarative
- Here mainly pay attention to the xplatform target platform and extprefix installation directory: JetsonNano QT5.12.9 cross-compilation and environment construction
-prefix 是QT编译后文件目录
-xplatform 是arm编译器类型,在qtbase/mkspecs目录下,根据自己交叉编译工具进行相应的替换
-no-opengl 跳过编译openGL(因为我已经安装了Qt,所以不需要界面)
-skip qtdeclarative 跳过 qtdeclarative(不跳过,编译出错,出错的原因不清楚)
如果有别的需求,可以./configure -help查看具体命令
- Pay attention to the information displayed on the terminal, and add the library (it has been added before, this is a screenshot of the error before adding): The success of
make is as follows:
Then直接make install
, you can see the installation we specified at the position of the -prefix parameter in the previous configure Directory:/home/feiyangq/myFile/Qt/Qt5.14.2-aarch64
The installation is successful! ! !
1.4 Qt configuration cross-compilation environment
1.4.1 Open Qt, add ARM64 compiler manually
Add the arm version qt just compiled and installed in qt creator . For detailed steps, refer to: Ubuntu20.04.1 (X86_64) Qt5.14.2 Configure ARM64 cross-compilation environment
But open the compiler part, I can already see the arm64 compilation in Auto-detected device. It may be because I compiled the source code first, and then installed Qt with the run file:
add GCC's C/C++ compiler aarch64-linux-gnu-gcc / g++
, and checked aarch64-linux-gnu-cpp curiously, cpp is The C Preprocessor (preprocessor) :
- Check the location of the compiler and study
usr/
the directory:
Research on the usr directory: What is the meaning of usr in the /usr directory of the Linux system ? Summary of the difference between /bin and /usr/local/bin/ Summary points:
- Without changing the configure file, the application installed by the Automake tool will be installed in
/usr/local/
the directory; - usr is the abbreviation of Unix Software Resource, which is the directory where the software resources of the Unix operating system are placed, rather than user data; all system default software will be placed in /usr, and this directory will occupy the most hard disk capacity when the system is installed
/bin
It is some instructions of the system./sbin
Generally refers to the super user command./usr/bin
It is the running script of some software you installed later./usr/sbin
Place some necessary programs for system management installed by users, such as: dhcpd, httpd, imap, in.*d, inetd, named, netconfig, squid, swap, tcpd, tcpdump, etc.- When the newly installed system runs some normal commands such as shutdown and fdisk, it prompts: bash:command not found . Then we must first consider whether these environment variables have been included in root .
$PATH
You can check the PATH , if it is:PATH=$PATH:$HOME/bin
you need to add the following:PATH=$PATH:$HOME/bin:/sbin:/usr/bin:/usr/sbin
- View the files related to aarch in usr/bin/
and then look at the aarch64-linux-gun folder in usr/
: enter the folder to view the contents as follows:
- Without changing the configure file, the application installed by the Automake tool will be installed in
1.4.2 Add QT Versions
In QT Versions, add the cross-compiled version of Qt obtained by compiling the source code before :
1.4.2 Add build kits (Kits)
1.5 Create a new project & compile, and test whether it is successful
1.5.1 New project & compile
- Create a new project, and select the aarch64 kit when the kits are selected:
build Build the project, and the obtained project folder is as follows:
- View file properties: Verification successful! ! !
1.5.2 Transfer the file to the Jetson nano development board for testing
Qt installation and testing of Jetson nano: to be continued. . . .
2. Configure cross-compilation environment in Docker
2.1Docker installation
See the article: Docker installation (Ubuntu 20.04 LTS) (including the introduction to the official documentation)
to be continued. . . . .
A hole has been opened and will continue to be updated as the project progresses.