ARM QT Cross-Compiling
I. Installing the cross compiler
I now use here is the Huawei Hers series arm-hisiv500-linux
aarch64-himix100-linux
Hi3519AV100
chip.
- Unzip the cross compiler compression package
- Execute the installation script with the suffix install, such as
aarch64-himix100-linux.install
. Different series of cross compilers will be installed in the default directory/opt/hisi-linux/x86-arm
, according to The name of the series is distinguished.
[root@test ]# ll /opt/hisi-linux/x86-arm/
total 8
drwxr-xr-x. 12 520 520 4096 Aug 22 13:55 aarch64-himix100-linux
drwxr-xr-x. 10 520 520 4096 Aug 22 13:44 arm-hisiv500-linux
- Configure the environment variables. The HiSilicon chip automatically configures the cross-compiler and configures the environment variables. You do not need to manually configure it yourself. If not configured, you need to change the
/etc/profile
file and add environment variables at the end, such as:
export PATH="/opt/hisi-linux/x86-arm/aarch64-himix100-linux/bin:$PATH"
Then, execute the following command to make it effective:
source /etc/profile
II. Download QT
- Go to the official website to download the QT source code of your required version:
http://download.qt.io/archive/qt/
The QT version I used is 4.8.7
http://download.qt.io/archive/qt/4.8/4.8.7/qt-everywhere-opensource-src-4.8.7.tar.gz - Unzip
tar -zxvf qt-everywhere-opensource-src-4.8.7.tar.gz
- Enter the directory
cd qt-everywhere-opensource-src-4.8.7
III. Configuring QT
- Configure the qmake.conf configuration file, first copy a template configuration file for customization:
cp -r ./mkspecs/qws/linux-arm-g++ ./mkspecs/qws/linux-himix100-g++
Edit the configuration file:
gedit ./mkspecs/qws/linux-himix100-g++/qmake.conf
Replace arm-linux
with the corresponding compiler, such as aarch64-himix100-linux
. Finally, the entire file looks like this:
#
# qmake configuration for building with arm-linux-g++
#
include(../../common/linux.conf)
include(../../common/gcc-base-unix.conf)
include(../../common/g++-unix.conf)
include(../../common/qws.conf)
# modifications to g++.conf
QMAKE_CC = aarch64-himix100-linux-gcc
QMAKE_CXX = aarch64-himix100-linux-g++
QMAKE_LINK = aarch64-himix100-linux-g++
QMAKE_LINK_SHLIB = aarch64-himix100-linux-g++
# modifications to linux.conf
QMAKE_AR = aarch64-himix100-linux-ar cqs
QMAKE_OBJCOPY = aarch64-himix100-linux-objcopy
QMAKE_STRIP = aarch64-himix100-linux-strip
load(qt_config)
- configure
1). 32-bit cross compiler configuration such asarm-hisiv500-linux
andHi3519AV100
:
./configure -opensource -confirm-license -embedded arm -nomake examples -nomake demos -nomake docs -xplatform qws/linux-hisiv500-g++ -prefix /usr/local/Trolltech/QtEmbedded-4.8.7-arm_x32
Among them, qws/linux-hisiv500-g++
needs to be modified according to different compilers.
The installation directory /usr/local/Trolltech/QtEmbedded-4.8.7-arm_x32
can also be customized as needed. The default installation directory is /usr/local/Trolltech/
, and the name is automatically named according to the Qt version and compiler architecture.
- configure
2).aarch64-himix100-linux
64-bit cross compiler configuration:
./configure -opensource -confirm-license -qt-sql-sqlite -qt-gfx-linuxfb -plugin-sql-sqlit -no-qt3support -no-phonon -no-svg -no-webkit -no-javascript-jit -no-script -no-scripttools -no-declarative -no-declarative-debug -qt-zlib -no-gif -qt-libtiff -qt-libpng -no-libmng -qt-libjpeg -no-rpath -no-pch -no-3dnow -no-avx -no-neon -no-openssl -no-nis -no-cups -no-dbus -embedded arm -platform linux-g++ -little-endian -qt-freetype -no-opengl -no-glib -nomake demos -nomake examples -nomake docs -xplatform qws/linux-himix100-g++ -prefix /usr/local/Trolltech/QtEmbedded-4.8.7-arm_x64
Similarly, qws/linux-himix100-g++
needs to be modified according to different compilers.
The installation directory /usr/local/Trolltech/QtEmbedded-4.8.7-arm_x64
can also be defined as needed. The default installation directory is /usr/local/Trolltech/
, and the name is automatically named according to the Qt version and the compiler architecture.
IV. 64-bit compiler extra configuration:
- Edit the
q_atomic_swp.h
header file to resolve the assembly swap error at compile time.
gedit ./src/corelib/arch/qatomic_armv5.h
Modify the q_atomic_swp
function to:
inline char q_atomic_swp(volatile char *ptr, char newval)
{
register char ret;
/*asm volatile("swpb %0,%2,[%3]"
: "=&r"(ret), "=m" (*ptr)
: "r"(newval), "r"(ptr)
: "cc", "memory");*/
ret=*ptr;
*ptr=newval;
return ret;
}
- Modify itemviews.cpp line 396 to resolve compilation errors:
error: invalid conversion frome 'int' to
vi src/plugins/accessible/widgets/itemviews.cpp +396
After modification, it is:
view()->selectionModel()->select(index, QItemSelectionModel::SelectionFlags( QItemSelectionModel::Columns & QItemSelectionModel::Deselect ));
V. Compile and install
Compile
gmake -j8
- Installation
gmake install
VI. Configuring Qt Creator
Configured in the toolbar Tools->Options->Build & Run
tab, there is no explanation here, as shown in the figure:
Reference:
https://doc.qt.io/archives/qt-4.8/qt-embedded-crosscompiling.html
https://blog.csdn.net/yfkyfk521/article/details/89446969