共计 18607 个字符,预计需要花费 47 分钟才能阅读完成。
Ubuntu18.04 实现 Aarch64 和 arm32 的穿插编译全步骤(含 Qt5.12.10 源码编译)
本文所应用的文件下载:
百度网盘:
链接:https://pan.baidu.com/s/1mnpFepFY-rOlwWd3QbYZiw
提取码:5566
下载穿插编译链接工具
)
装置穿插编译器
解压
sudo tar -xvf gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar -C /opt/
sudo tar -xvf gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar -C /opt/
解压实现后,配置环境变量
sudo vim ~/.bashrc
增加编译器门路:门路为你解压后门路,我的门路为:/opt/
PATH=$PATH:/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin
PATH=$PATH:/opt/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin
配置失效
source ~/.bashrc
验证是否装置胜利
aarch64-linux-gnu-gcc -v
arm-linux-gnueabihf-gcc -v
arm32 如下为胜利。
aarch64 如下为胜利
测试穿插编译器
写一个简略的 c 程序,穿插编译后放到开发板下来运行看看 是否运行胜利
#include <stdio.h>
int main(int argc, char **argv)
{printf("Hello, you do it succeed!!!\n");
return 0;
}
- 先应用 arm32 编译
编译实现后,看到文件是 32 位的。
移植到 arm32 板子上,能够运行胜利。
- aarch64 编译
编译实现后,看到文件是 arm 64 位的。
移植到 aarch64 的板子上,能够运行胜利。
由此可见,两种穿插编译工具都装置胜利,能够应用。
编译 Qt 源码
这里只是用 aarch64 编译器去编译 qt 源码
下载 Qt 源码
解压 qt 源码
sudo tar xvf qt-everywhere-src-5.12.10.tar.xz
cd qt-everywhere-src-5.12.10
批改 qmake 配置文件
首先复制一份文件
sudo cp -a linux-aarch64-gnu-g++/ aarch64-linux-gnu-g++/
批改配置文件目录,前面都改成你穿插编译器装置的门路。”/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/“
# modifications to g++.conf
QMAKE_CC = /opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc
QMAKE_CXX = /opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++
QMAKE_LINK = /opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++
QMAKE_LINK_SHLIB = /opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++
# modifications to linux.conf
QMAKE_AR = /opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-ar cqs
QMAKE_OBJCOPY = /opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-objcopy
QMAKE_NM = /opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc-nm -P
QMAKE_STRIP = /opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-strip
load(qt_config)
# modifications to g++.conf
QMAKE_CC = /opt/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabi-gcc
QMAKE_CXX = /opt/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabi-g++
QMAKE_LINK = /opt/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabi-g++
QMAKE_LINK_SHLIB = /opt/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabi-g++
# modifications to linux.conf
QMAKE_AR = /opt/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabi-ar cqs
QMAKE_OBJCOPY = /opt/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabi-objcopy
QMAKE_NM = /opt/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabi-nm -P
QMAKE_STRIP = /opt/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabi-strip
配置编译参数
Linux 下 qt5 的装置及库编译(1)_hrx-@@-CSDN 博客
qt5 的 configure 选项阐明(2)_hrx-@@-CSDN 博客
- 倡议是新建一个 build 目录,而后在该目录下配置 configure,make 之类的,这样子配置编译生成的临时文件会放在该目录下,而不会污染源码。
- 在 build 目录下创立一个 build.sh 的脚本,增加如下内容
../qt-everywhere-src-5.12.10/configure \
-verbose \
-opensource \
-release \
-shared \
-confirm-license \
-make libs \
-nomake tests \
-nomake examples \
-skip qtmacextras \
-skip qtandroidextras \
-no-opengl \
-xplatform aarch64-linux-gnu-g++ \
-prefix /opt/qt-5.12.10-linux-aarch64-gcc
verbose:打印配置过程中步骤信息
opensource:编译 Qt 的开源版本
release:编译 Qt 的 release 版本
shared:构建 Qt 共享库
confirm-license:主动确认许可
make libs:编译 lib 组件
nomake tests:不编译 tests 组件
nomake examples:不编译 examples 组件
skip qtmacextras:跳过 qtmacextras 模块
skip qtandroidextras:跳过 qtandroidextras 模块
no-opengl: 我在虚拟机下编译 opengl 模块报错,未解决 所以抉择不编译
xplatform:抉择穿插编译时的指标 mkspec
prefix:指定 make install 的地位
./configure -release -opensource -confirm-license -xplatform aarch64-linux-gnu-gcc -prefix /opt/aarch64—qt5 -nomake examples -nomake tools -nomake tests -no-opengl
装置编译所依赖的库
- 装置根底的编译环境
sudo apt-get build-dep qt5-default
sudo apt-get install libxcb-xinerama0-dev
sudo apt-get install build-essential perl python git
-
Libxcb
sudo apt-get install '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev
-
OpenGL
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
-
Qt WebKit
sudo apt-get install flex bison gperf libicu-dev libxslt-dev ruby
-
Qt WebEngine
sudo apt-get install libssl-dev libxcursor-dev libxcomposite-dev libxdamage-dev libxrandr-dev libdbus-1-dev libfontconfig1-dev libcap-dev libxtst-dev libpulse-dev libudev-dev libpci-dev libnss3-dev libasound2-dev libxss-dev libegl1-mesa-dev gperf bison
-
Qt Multimedia
sudo apt-get install libasound2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev
-
QDoc Documentation Generator Tool
sudo apt install libclang-6.0-dev llvm-6.0
执行 build 脚本 构建选项:
Build options:
Mode ................................... release
Optimize release build for size ........ no
Building shared libraries .............. yes
Using C standard ....................... C11
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:
SSE .................................. SSE2 SSE3 SSSE3 SSE4.1 SSE4.2
AVX .................................. AVX AVX2
AVX512 ............................... F ER CD PF DQ BW VL IFMA VBMI
Other x86 ............................ AES F16C RDRAND SHA
Intrinsics without -mXXX option ...... yes
Build parts ............................ libs
Qt modules and options:
Qt Concurrent .......................... yes
Qt D-Bus ............................... yes
Qt D-Bus directly linked to libdbus .... yes
Qt Gui ................................. yes
Qt Network ............................. yes
Qt Sql ................................. yes
Qt Testlib ............................. yes
Qt Widgets ............................. yes
Qt Xml ................................. yes
Support enabled for:
Using pkg-config ....................... yes
udev ................................... yes
Using system zlib ...................... yes
Qt Core:
DoubleConversion ....................... yes
Using system DoubleConversion ........ no
GLib ................................... yes
iconv .................................. no
ICU .................................... yes
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 ................................ yes
Qt directly linked to OpenSSL ........ no
OpenSSL 1.1 ............................ yes
DTLS ................................... yes
SCTP ................................... no
Use system proxies ..................... yes
Qt Gui:
Accessibility .......................... yes
FreeType ............................... yes
Using system FreeType ................ yes
HarfBuzz ............................... yes
Using system HarfBuzz ................ yes
Fontconfig ............................. yes
Image formats:
GIF .................................. yes
ICO .................................. yes
JPEG ................................. yes
Using system libjpeg ............... no
PNG .................................. yes
Using system libpng ................ yes
EGL .................................... yes
OpenVG ................................. no
OpenGL:
Desktop OpenGL ....................... yes
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 .............................. yes
X11 specific:
XLib ................................. yes
XCB Xlib ............................. yes
EGL on X11 ........................... yes
QPA backends:
DirectFB ............................... no
EGLFS .................................. yes
EGLFS details:
EGLFS OpenWFD ........................ no
EGLFS i.Mx6 .......................... no
EGLFS i.Mx6 Wayland .................. no
EGLFS RCAR ........................... no
EGLFS EGLDevice ...................... yes
EGLFS GBM ............................ no
EGLFS VSP2 ........................... no
EGLFS Mali ........................... no
EGLFS Raspberry Pi ................... no
EGLFS X11 ............................ yes
LinuxFB ................................ yes
VNC .................................... yes
Mir client ............................. no
XCB:
Using system-provided XCB libraries .. yes
XCB XKB .............................. yes
XCB XInput ........................... yes
Native painting (experimental) ....... yes
GL integrations:
GLX Plugin ......................... yes
XCB GLX .......................... yes
EGL-X11 Plugin ..................... yes
Qt Sql:
SQL item models ........................ yes
Qt Widgets:
GTK+ ................................... no
Styles ................................. Fusion Windows
Qt PrintSupport:
CUPS ................................... no
Qt Sql Drivers:
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
Further Image Formats:
JasPer ................................. no
MNG .................................... no
TIFF ................................... yes
Using system libtiff ................. no
WEBP ................................... yes
Using system libwebp ................. no
Qt QML:
QML network support .................... yes
QML debugging and profiling support .... yes
QML sequence object .................... yes
QML list model ......................... yes
QML XML http request ................... yes
QML Locale ............................. 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
TableView item ......................... yes
Path support ........................... yes
PathView item .......................... yes
Positioner items ....................... yes
Repeater item .......................... yes
ShaderEffect item ...................... yes
Sprite item ............................ yes
Qt Scxml:
ECMAScript data model for QtScxml ...... yes
Qt Gamepad:
SDL2 ................................... no
Qt 3D:
Assimp ................................. yes
System Assimp .......................... no
Output Qt3D Job traces ................. no
Output Qt3D GL traces .................. no
Use SSE2 instructions .................. yes
Use AVX2 instructions .................. no
Aspects:
Render aspect ........................ yes
Input aspect ......................... yes
Logic aspect ......................... yes
Animation aspect ..................... yes
Extras aspect ........................ yes
Qt 3D Renderers:
OpenGL Renderer ........................ yes
Qt 3D GeometryLoaders:
Autodesk FBX ........................... no
Qt Wayland Drivers:
EGL .................................... yes
Raspberry Pi ........................... no
XComposite EGL ......................... yes
XComposite GLX ......................... yes
DRM EGL ................................ yes
libhybris EGL .......................... no
Linux dma-buf server buffer integration . yes
Vulkan-based server buffer integration . no
Shm emulation server buffer integration . yes
Qt Wayland Client ........................ yes
Qt Wayland Compositor .................... yes
Qt Wayland Compositor Layer Plugins:
VSP2 hardware layer integration ........ no
Qt Bluetooth:
BlueZ .................................. no
BlueZ Low Energy ....................... no
Linux Crypto API ....................... no
WinRT Bluetooth API (desktop & UWP) .... no
Qt Sensors:
sensorfw ............................... no
Qt Quick Controls 2:
Styles ................................. Default Fusion Imagine Material Universal
Qt Quick Templates 2:
Hover support .......................... yes
Multi-touch support .................... yes
Qt Positioning:
Gypsy GPS Daemon ....................... no
WinRT Geolocation API .................. no
Qt Location:
Qt.labs.location experimental QML plugin . yes
Geoservice plugins:
OpenStreetMap ........................ yes
HERE ................................. yes
Esri ................................. yes
Mapbox ............................... yes
MapboxGL ............................. yes
Itemsoverlay ......................... yes
QtXmlPatterns:
XML schema support ..................... yes
Qt Multimedia:
ALSA ................................... yes
GStreamer 1.0 .......................... no
GStreamer 0.10 ......................... no
Video for Linux ........................ yes
OpenAL ................................. no
PulseAudio ............................. yes
Resource Policy (libresourceqt5) ....... no
Windows Audio Services ................. no
DirectShow ............................. no
Windows Media Foundation ............... no
Qt Tools:
QDoc ................................... yes
Qt WebEngine:
Embedded build ......................... no
Full debug information ................. no
Pepper Plugins ......................... yes
Printing and PDF ....................... yes
Proprietary Codecs ..................... no
Spellchecker ........................... yes
Native Spellchecker .................... no
WebRTC ................................. yes
Use System Ninja ....................... no
Geolocation ............................ yes
WebChannel support ..................... yes
Use v8 snapshot ........................ yes
Kerberos Authentication ................ no
Support qpa-xcb ........................ yes
Use ALSA ............................... yes
Use PulseAudio ......................... yes
Optional system libraries used:
re2 .................................. no
icu .................................. no
libwebp, libwebpmux and libwebpdemux . no
opus ................................. no
ffmpeg ............................... no
libvpx ............................... no
snappy ............................... no
glib ................................. yes
zlib ................................. yes
minizip .............................. no
libevent ............................. no
jsoncpp .............................. no
protobuf ............................. no
libxml2 and libxslt .................. yes
lcms2 ................................ no
png .................................. yes
JPEG ................................. no
harfbuzz ............................. yes
freetype ............................. yes
Required system libraries:
fontconfig ........................... yes
dbus ................................. yes
nss .................................. yes
khr .................................. yes
glibc ................................ yes
Required system libraries for qpa-xcb:
x11 .................................. yes
libdrm ............................... yes
xcomposite ........................... yes
xcursor .............................. yes
xi ................................... yes
xtst ................................. yes
Note: Also available for Linux: linux-clang linux-icc
Note: Disabling X11 Accessibility Bridge: D-Bus or AT-SPI is missing.
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-5.12.10-linux-aarch64'.
Prior to reconfiguration, make sure you remove any leftovers from
the previous build.
执行 make
对源码进行编译,工夫挺长的, 大概三四个小时 。
make -j8
执行 make install
sudo make install
在编译实现后执行 make install 会将 qt 库装置到 -prefix 指定的目录下。
查看库的零碎架构
能够库装置门路上面,readelf – h xxx.so 能够看到编译进去的库零碎架构是 Aarch64 的。
配置 qtcreator 穿插编译环境
在 ubuntu 下搭建 Qt Creator 的 arm 穿插编译环境_bigmarshal 的博客 -CSDN 博客
首先没有装置 qtcreator,须要装置
sudo apt-get install qtcreator
增加穿插编译工具链
编译器门路,抉择你之前装置的门路,我的门路为:
c++
/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++
c
/opt/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc
抉择 qmake 版本,门路为你编译输入的门路。
增加 Kit
创立个带界面的工程进行穿插编译测试
抉择 Aarch64 编译
程序依赖库也是失常的。
能够看出编译生成的应用程序是 ARM aarch64 的。接下来打包后移植到 rk3399 中执行关上。
最初能够看出功败垂成~~~
疑难?
- 如果用 rk3399 上所有 qt 的依赖库,再加上 qmake 和 gcc 编译工具,不晓得是否能够跳过编译 qt 源码这个步骤,间接应用现有的依赖库?
- 可能间接能够应用他人穿插编译后的依赖库曾经 qmake 等编译工具?
遇到的问题
编译 opengl 模块报错
WARNING: QDoc will not be compiled, probably because libclang could not be located. This means that you cannot build the Qt documentation.
Either ensure that llvm-config is in your PATH environment variable, or set LLVM_INSTALL_DIR to the location of your llvm installation.
On Linux systems, you may be able to install libclang by installing the libclang-dev or libclang-devel package, depending on your distribution.
On macOS, you can use Homebrew's llvm package.
On Windows, you must set LLVM_INSTALL_DIR to the installation path.
WARNING: Python version 2 (2.7.5 or later) is required to build QtWebEngine.
WARNING: gperf is required to build QtWebEngine.
WARNING: bison is required to build QtWebEngine.
WARNING: flex is required to build QtWebEngine.
WARNING: host pkg-config not found
ERROR: The OpenGL functionality tests failed!
You might need to modify the include and library search paths by editing QMAKE_INCDIR_OPENGL[_ES2],
QMAKE_LIBDIR_OPENGL[_ES2] and QMAKE_LIBS_OPENGL[_ES2] in the mkspec for your platform.
imx6 qt5 编译出错“QMAKE_INCDIR_OPENGL_ES2, QMAKE_LIBDIR_OPENGL_ES2″ – i.MX – 恩智浦技术社区 (nxpic.org.cn)
QMAKE_INCDIR += /usr/include
QMAKE_LIBDIR += /usr/lib
ERROR: The OpenGL functionality tests failed!
You might need to modify the include and library search paths by editing QMAKE_INCDIR_OPENGL[_ES2],
QMAKE_LIBDIR_OPENGL[_ES2] and QMAKE_LIBS_OPENGL[_ES2] in the mkspec for your platform.
QMAKE_INCDIR_EGL = /usr/include
QMAKE_LIBDIR_EGL = /usr/lib
QMAKE_INCDIR_OPENGL_ES2 = /usr/include
QMAKE_LIBDIR_OPENGL_ES2 = /usr/lib
QMAKE_LIBS_EGL += -lEGL
QMAKE_LIBS_OPENGL_ES2 += -lGLESv2 -lEGL -lGAL
QMAKE_INCDIR += /usr/include
QMAKE_LIBDIR += /usr/lib
configuring Qt5.15 source on Ubuntu 20.04 opengl necessary for qt-quick – Stack Overflow
sudo ./configure -no-opengl -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=/opt/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf- -opensource -confirm-license -optimized-qmake -reduce-exports -release -make libs -prefix /opt/qt5_amr32
- ./configure -release -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- -sysroot ~/raspi/sysroot -opensource -confirm-license -skip qtwayland -skip qtlocation -skip qtscript -make libs -prefix /usr/local/qt5pi -extprefix ~/raspi/qt5pi -hostprefix ~/raspi/qt5 -no-use-gold-linker -v -no-gbm
- $ ./configure -opengl es2 -device linux-rasp-pi3-g++ -device-option CROSS_COMPILE=/home/wind/opt/raspi/tools/arm-bcm2708/gcc-linaro-4.9-2015.02-3-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf- -sysroot /mnt -opensource -confirm-license -optimized-qmake -reduce-exports -release -make libs -prefix /usr/local/qt5