移植QT 5.11.3 linuxfb文件系统(STM32MP157)

移植QT 5.11.3 linuxfb文件系统(STM32MP157)

发现最近随便转载的很多啊,未经授权禁止转载!抄袭!!否则转载者死全家!!另外这是我的笔记,不是教程,难免会有错误,不具有很高的参考性,望周知。

步骤

解压qt-everywhere-src-5.11.3.tar.xz到/opt目录下:

1
sudo tar -xvf qt-everywhere-src-5.11.3.tar.xz -C /opt

进入/opt/qt-everywhere-src-5.11.3目录:

1
cd /opt/qt-everywhere-src-5.11.3

安装依赖(参考野火):

1
2
3
4
5
6
sudo apt install python -y
sudo apt install g++ make qt3d5-dev-tools -y
sudo apt install qml-module-qtquick-xmllistmodel -y
sudo apt install qml-module-qtquick-virtualkeyboard qml-module-qtquick-privatewidgets qml-module-qtquick-dialogs qml -y
sudo apt install libqt53dquickscene2d5 libqt53dquickrender5 libqt53dquickinput5 libqt53dquickextras5 libqt53dquickanimation5 libqt53dquick5 -y
sudo apt install qtdeclarative5-dev qml-module-qtwebengine qml-module-qtwebchannel qml-module-qtmultimedia qml-module-qtaudioengine -y

修改qmake.conf配置文件:

1
vi qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf

修改如下(主要修改交叉编译器路径):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#
# 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-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
QMAKE_CXX = /opt/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++
QMAKE_LINK = /opt/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++
QMAKE_LINK_SHLIB = /opt/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++

# modifications to linux.conf
QMAKE_AR = /opt/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ar cqs
QMAKE_OBJCOPY = /opt/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-objcopy
QMAKE_NM = /opt/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-nm -P
QMAKE_STRIP = /opt/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-strip
load(qt_config)

查看特征列表:

1
./configure -list-features

这里时间比较长,耐心等一下,大概两分钟。

设置编译选项(参考野火和正点原子):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
./configure \
-prefix /opt/qt-armhf-5.11.3 \
-xplatform linux-arm-gnueabi-g++ \
-release \
-opensource \
-confirm-license \
-no-openssl \
-no-opengl \
-no-xcb \
-no-compile-examples \
-no-pkg-config \
-no-iconv \
-no-glib \
-skip qt3d \
-skip qtactiveqt \
-skip qtandroidextras \
-skip qtcanvas3d \
-skip qtconnectivity \
-skip qtdatavis3d \
-skip qtdoc \
-skip qtgamepad \
-skip qtlocation \
-skip qtmacextras \
-skip qtnetworkauth \
-skip qtpurchasing \
-skip qtremoteobjects \
-skip qtscript \
-skip qtscxml \
-skip qtsensors \
-skip qtspeech \
-skip qtsvg \
-skip qttools \
-skip qttranslations \
-skip qtwayland \
-skip qtwebengine \
-skip qtwebview \
-skip qtwinextras \
-skip qtx11extras \
-skip qtxmlpatterns \

输出:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
Creating qmake...
.Done.

This is the Qt Open Source Edition.

You have already accepted the terms of the Open Source license.

Running configuration tests...
Done running configuration tests.

Configure summary:

Building on: linux-g++ (x86_64, CPU features: mmx sse sse2)
Building for: linux-arm-gnueabi-g++ (arm, CPU features: <none>)
Configuration: cross_compile use_gold_linker enable_new_dtags largefile precompile_header shared rpath release c++11 c++14 c++1z concurrent dbus no-pkg-config reduce_exports stl
Build options:
Mode ................................... release
Optimize release build for size ........ no
Building shared libraries .............. yes
Using C++ standard ..................... C++1z
Using ccache ........................... no
Using gold linker ...................... yes
Using new DTAGS ........................ yes
Using precompiled headers .............. yes
Using LTCG ............................. no
Target compiler supports:
NEON ................................. no
Build parts ............................ libs examples
Qt modules and options:
Qt Concurrent .......................... yes
Qt D-Bus ............................... yes
Qt D-Bus directly linked to libdbus .... no
Qt Gui ................................. yes
Qt Network ............................. yes
Qt Sql ................................. yes
Qt Testlib ............................. yes
Qt Widgets ............................. yes
Qt Xml ................................. yes
Support enabled for:
Using pkg-config ....................... no
udev ................................... no
Using system zlib ...................... no
Qt Core:
DoubleConversion ....................... yes
Using system DoubleConversion ........ no
GLib ................................... no
iconv .................................. no
ICU .................................... no
Tracing backend ........................ <none>
Logging backends:
journald ............................. no
syslog ............................... no
slog2 ................................ no
Using system PCRE2 ..................... no
Qt Network:
getifaddrs() ........................... yes
IPv6 ifname ............................ yes
libproxy ............................... no
Linux AF_NETLINK ....................... yes
OpenSSL ................................ no
Qt directly linked to OpenSSL ........ no
OpenSSL 1.1 ............................ no
SCTP ................................... no
Use system proxies ..................... yes
Qt Gui:
Accessibility .......................... yes
FreeType ............................... yes
Using system FreeType ................ no
HarfBuzz ............................... yes
Using system HarfBuzz ................ no
Fontconfig ............................. no
Image formats:
GIF .................................. yes
ICO .................................. yes
JPEG ................................. yes
Using system libjpeg ............... no
PNG .................................. yes
Using system libpng ................ no
EGL .................................... no
OpenVG ................................. no
OpenGL:
Desktop OpenGL ....................... no
OpenGL ES 2.0 ........................ no
OpenGL ES 3.0 ........................ no
OpenGL ES 3.1 ........................ no
OpenGL ES 3.2 ........................ no
Vulkan ................................. no
Session Management ..................... yes
Features used by QPA backends:
evdev .................................. yes
libinput ............................... no
INTEGRITY HID .......................... no
mtdev .................................. no
tslib .................................. no
xkbcommon-evdev ........................ no
QPA backends:
DirectFB ............................... no
EGLFS .................................. no
LinuxFB ................................ yes
VNC .................................... yes
Mir client ............................. no
Qt Widgets:
GTK+ ................................... no
Styles ................................. Fusion Windows
Qt PrintSupport:
CUPS ................................... no
Qt Sql:
DB2 (IBM) .............................. no
InterBase .............................. no
MySql .................................. no
OCI (Oracle) ........................... no
ODBC ................................... no
PostgreSQL ............................. no
SQLite2 ................................ no
SQLite ................................. yes
Using system provided SQLite ......... no
TDS (Sybase) ........................... no
Qt Testlib:
Tester for item models ................. yes
Qt SerialBus:
Socket CAN ............................. yes
Socket CAN FD .......................... yes
Qt QML:
QML network support .................... yes
QML debugging and profiling support .... yes
QML delegate model ..................... yes
Qt Quick:
Direct3D 12 ............................ no
AnimatedImage item ..................... yes
Canvas item ............................ yes
Support for Qt Quick Designer .......... yes
Flipable item .......................... yes
GridView item .......................... yes
ListView item .......................... yes
Path support ........................... yes
PathView item .......................... yes
Positioner items ....................... yes
Repeater item .......................... yes
ShaderEffect item ...................... yes
Sprite item ............................ yes
Qt Quick Controls 2:
Styles ................................. Default Fusion Imagine Material Universal
Qt Quick Templates 2:
Hover support .......................... yes
Multi-touch support .................... yes
Qt Multimedia:
ALSA ................................... no
GStreamer 1.0 .......................... no
GStreamer 0.10 ......................... no
Video for Linux ........................ yes
OpenAL ................................. no
PulseAudio ............................. no
Resource Policy (libresourceqt5) ....... no
Windows Audio Services ................. no
DirectShow ............................. no
Windows Media Foundation ............... no

Note: Also available for Linux: linux-clang linux-icc

Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into '/opt/qt-armhf-5.11.3'.

Prior to reconfiguration, make sure you remove any leftovers from
the previous build.

无报错,开始编译:

1
make -j4

漫长的过程,等啊等啊等啊等。。。。。我的电脑编译了近40分钟。

编译完成后没有成功的提示,只要日志没有错误信息就可以了。

然后安装:

1
sudo make install

安装完成后,进入/opt/qt-armhf-5.11.3目录会看到QT的文件。

在开发板上使用QT时,需要将这些文件拷贝到开发板相同的目录中才可以。

拷贝到nfs_rootfs目录:

1
sudo cp -r qt-armhf-5.11.3 ~/nfs_rootfs/opt

设置环境变量:

1
vi ~/.bashrc

添加如下内容:

1
2
3
4
5
export QTDIR=/opt/qt-armhf-5.11.3
export QT_QPA_PLATFORM_PLUGIN_PATH=$QTDIR/plugins
export LD_LIBRARY_PATH=$QTDIR/lib:$QTDIR/plugins/platforms
export QT_QPA_FONTDIR=$QTDIR/lib/fonts
export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0

建立字体存放文件夹:

1
sudo mkdir ~/nfs_rootfs/opt/qt-armhf-5.11.3/lib/fonts

下载文泉驿正黑字体:

1
sudo apt install fonts-wqy-zenhei

复制字体:

1
sudo cp /usr/share/fonts/truetype/wqy/wqy-zenhei.ttc ~/nfs_rootfs/opt/qt-armhf-5.11.3/lib/fonts/

运行时需要添加参数:

1
-platform linuxfb

完成!

参考资料:

[1] Qt源码编译configure参数列表(全)_尛少年的博客-CSDN博客_qt 编译参数

[2] Qt环境搭建–ARM — 嵌入式Qt应用开发实战——基于鲁班猫 文档 (embedfire.com)

坚持原创技术分享,您的支持是我前进的动力!