Qt5.12.8的QtWebEngine库编译随笔(rk3588板卡)
起因编译环境源码配置编译遇到问题 引用
起因
项目从rk3399板卡改为rk3588后原先的qtwebengine库直接无法使用了,故尝试在新的板卡下进行编译。
编译环境
板卡: rk3588
系统: unbuntu 20.04 LTS
gcc version: aarch64-linux-gnu 9.4.0
源码
下载地址:https://download.qt.io/new_archive/qt/5.12/5.12.8/single/
下载到板块后解压
sudo tar -xf qt-everywhere-src-5.12.8.tar.xzcd qt-everywhere-src-5.12.8
配置
由于配置的信息相当多,建议创建一个自动配置脚本,比如auto.sh,方便根据自己的系统进行参数调整。
sudo touch auto.shsudo chmod 755 auto.shsudo vim auto.sh
#auto.sh./configure -prefix /root/honglingfeng/arm-qt-5.12.8 \-opensource \-confirm-license \-release \-strip \-shared \-optimized-qmake \-c++std c++11 \--rpath=no \-pch \-webengine-proprietary-codecs \-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 qtwinextras \-skip qtx11extras \-skip qtxmlpatterns \-skip qtgraphicaleffects \-make libs \-nomake tools \-nomake tests \-gui \-widgets \-dbus-runtime \--glib=no \--iconv=no \--pcre=qt \-qt-zlib \-no-vulkan \-no-openssl \--freetype=qt \--harfbuzz=qt \-opengl es2 \-xcb \-xcb-xlib \-egl \-eglfs \--pcre=qt \-linuxfb \-no-tslib \-qt-libpng \-qt-libjpeg \--sqlite=qt \
具体configure参数解析可以参考以下文章:https://blog.csdn.net/qing666888/article/details/79597473
官方英文帮助文档: ./configure --help
注意:每次改变auto.sh里面的参数,记得将config.cache删除后在运行脚本
运行auto.sh脚本进行配置
因为缺少依赖文件,绝大部分情况下configure都无法通过的,即报WARNING: QtXXX will not be built.。所以必须要安装依赖文件,直到不报错为止。
root@ok3588:~/qtSource/qt-everywhere-src-5.12.8# sh auto.sh+ cd qtbase+ /root/qtSource/qt-everywhere-src-5.12.8/qtbase/configure -top-level -prefix /root/honglingfeng/arm-qt-5.12.8 -opensource -confirm-license -release -strip -shared -optimized-qmake -c++std c++11 --rpath=no -pch -webengine-proprietary-codecs -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 qtwinextras -skip qtx11extras -skip qtxmlpatterns -skip qtgraphicaleffects -make libs -nomake tools -nomake tests -gui -widgets -dbus-runtime --glib=no --iconv=no --pcre=qt -qt-zlib -no-vulkan -no-openssl --freetype=qt --harfbuzz=qt -opengl es2 -xcb -xcb-xlib -egl -eglfs --pcre=qt -linuxfb -no-tslib -qt-libpng -qt-libjpeg --sqlite=qtCreating qmake....Done.This is the Qt Open Source Edition.You have already accepted the terms of the Open Source license.Running configuration tests...Checking for gold linker... yesChecking for machine tuple... yesChecking for valid makespec... yesChecking for target architecture... arm64Checking for alloca() in alloca.h... yesChecking for C99 support... yesChecking for C11 support... yesChecking for new dtags support... yesChecking for pkg-config... yesChecking for D-Bus >= 1.2 (host)... yesChecking for udev... yesChecking for POSIX fallocate()... yesChecking for precompiled header support... yesChecking for RDRAND instruction... noChecking for symbol visibility support... yesChecking for -Bsymbolic-functions support... noChecking for STL compatibility... yesChecking for clock_gettime()... yesChecking for POSIX monotonic clock... yesChecking for C++11 <future>... yesChecking for dlopen()... yesChecking for eventfd... yesChecking for futimens()... yesChecking for getauxval()... yesChecking for getentropy()... yesChecking for GNU libc... yesChecking for ICU... yesChecking for inotify... yesChecking for SysV IPC... yesChecking for linkat()... yesChecking for ppoll()... yesChecking for renameat2()... yesChecking for slog2... noChecking for statx() in libc... yesChecking for 64 bit atomics... yesChecking for DoubleConversion... noChecking for O_CLOEXEC... yesChecking for C++11 <random>... yesChecking for working std::atomic for function pointers... yesChecking for getifaddrs()... yesChecking for IPv6 ifname... yesChecking for Linux AF_NETLINK sockets... yesChecking for xkbcommon >= 0.5.0... yesChecking for XCB >= 1.9... yesChecking for atspi... yesChecking for OpenGL ES 2.0... yesChecking for KMS... yesChecking for DRM Atomic API... yesChecking for EGL... yesChecking for XLib... yesChecking for EGL on X11... yesChecking for EGLDevice... yesChecking for GBM... noChecking for Mali EGL... noChecking for Mali 2 EGL... noChecking for i.Mx6 EGL... noChecking for XCB Xlib... yesChecking for evdev... yesChecking for libinput... noChecking for LinuxFB... yesChecking for mtdev... noChecking for OpenGL ES 3.0... yesChecking for OpenGL ES 3.1... yesChecking for OpenGL ES 3.2... yesChecking for OpenVG... noChecking for default QPA platform... xcbChecking for XCB ICCCM >= 0.3.9... yesChecking for XCB SHM... yesChecking for XCB Image >= 0.3.9... yesChecking for XCB Keysyms >= 0.3.9... yesChecking for XCB RandR... yesChecking for XCB XRender... yesChecking for XCB Renderutil >= 0.3.9... yesChecking for XCB Shape... yesChecking for XCB Sync... yesChecking for XCB Xfixes... yesChecking for XCB Xinerama... yesChecking for XCB (extensions)... yesChecking for X11 prefix... /usrChecking for X11 session management... yesChecking for XCB XInput... yesChecking for XCB XKB >= 1.10... yesChecking for xkbcommon-x11... yesChecking for CUPS... yesChecking for DB2 (IBM)... noChecking for InterBase... noChecking for MySQL... noChecking for OCI (Oracle)... noChecking for ODBC... noChecking for PostgreSQL... noChecking for SQLite (version 2)... noChecking for TDS (Sybase)... noChecking for Socket CAN... yesChecking for Socket CAN FD... yesChecking for jasper... noChecking for mng... noChecking for tiff... yesChecking for webp... noChecking for C++14 make_unique()... noChecking for Direct3D 12... noChecking for ALSA... yesChecking for Vivante GPU... noChecking for GStreamer 1.0... noChecking for GStreamer 0.10... noChecking for Video for Linux... yesChecking for OpenAL... noChecking for PulseAudio >= 0.9.10... yesChecking for libresourceqt5... noChecking for alsa... yesChecking for embedded... noChecking for bison... yesChecking for flex... yesChecking for gperf... yesChecking for host pkg-config... /usr/bin/pkg-configChecking for linker supports -z noexecstack... yesChecking for x11... yesChecking for libdrm... yesChecking for xcomposite... yesChecking for xcursor... yesChecking for xi... yesChecking for xtst... yesChecking for poppler-cpp... noChecking for pulseaudio >= 0.9.10... yesChecking for python2... /usr/bin/python2Checking for d-bus... yesChecking for fontconfig... yesChecking for glib-2.0 >= 2.32.0... yesChecking for glibc > 2.16... yesChecking for jsoncpp... noChecking for khr... yesChecking for lcms2... noChecking for libevent... noChecking for libvpx... noChecking for libwebp, libwebpmux and libwebpdemux... noChecking for libxml2 and libxslt... noChecking for minizip... noChecking for system ninja... noChecking for nss >= 3.26... yesChecking for opus... noChecking for protobuf... noChecking for re2... noChecking for snappy... noDone running configuration tests.Configure summary:Build type: linux-g++ (arm64, CPU features: cx16 neon)Compiler: gcc 9.4.0Configuration: use_gold_linker compile_examples enable_new_dtags largefile neon precompile_header shared release c++11 concurrent dbus reduce_exports release_tools stlBuild options: Mode ................................... release; optimized tools Optimize release build for size ........ no Building shared libraries .............. yes Using C standard ....................... C11 Using C++ standard ..................... C++11 Using ccache ........................... no Using gold linker ...................... yes Using new DTAGS ........................ yes Using precompiled headers .............. yes Using LTCG ............................. no Target compiler supports: NEON ................................. yes Build parts ............................ libsQt 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 ................................. yesSupport enabled for: Using pkg-config ....................... yes udev ................................... yes Using system zlib ...................... noQt Core: DoubleConversion ....................... yes Using system DoubleConversion ........ no GLib ................................... no iconv .................................. no ICU .................................... yes Tracing backend ........................ <none> Logging backends: journald ............................. no syslog ............................... no slog2 ................................ no Using system PCRE2 ..................... noQt Network: getifaddrs() ........................... yes IPv6 ifname ............................ yes libproxy ............................... no Linux AF_NETLINK ....................... yes OpenSSL ................................ no Qt directly linked to OpenSSL ........ no OpenSSL 1.1 ............................ no DTLS ................................... no SCTP ................................... no Use system proxies ..................... yesQt 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 .................................... yes OpenVG ................................. no OpenGL: Desktop OpenGL ....................... no OpenGL ES 2.0 ........................ yes OpenGL ES 3.0 ........................ yes OpenGL ES 3.1 ........................ yes OpenGL ES 3.2 ........................ yes Vulkan ................................. no Session Management ..................... yesFeatures 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 ........................... yesQPA 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) ....... no GL integrations: GLX Plugin ......................... no EGL-X11 Plugin ..................... yesQt Sql: SQL item models ........................ yesQt Widgets: GTK+ ................................... no Styles ................................. Fusion WindowsQt PrintSupport: CUPS ................................... yesQt 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) ........................... noQt Testlib: Tester for item models ................. yesQt SerialBus: Socket CAN ............................. yes Socket CAN FD .......................... yesFurther Image Formats: JasPer ................................. no MNG .................................... no TIFF ................................... yes Using system libtiff ................. yes WEBP ................................... yes Using system libwebp ................. noQt 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 ..................... yesQt 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 ............................ yesQt 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 ............... noQt WebEngine: Embedded build ......................... no Full debug information ................. no Pepper Plugins ......................... yes Printing and PDF ....................... yes Proprietary Codecs ..................... yes Spellchecker ........................... yes Native Spellchecker .................... no WebRTC ................................. yes Use System Ninja ....................... no Geolocation ............................ no 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 ................................. no minizip .............................. no libevent ............................. no jsoncpp .............................. no protobuf ............................. no libxml2 and libxslt .................. no lcms2 ................................ no png .................................. no JPEG ................................. no harfbuzz ............................. no freetype ............................. no 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 ................................. yesNote: Also available for Linux: linux-clang linux-iccNote: -optimized-tools is not useful in -release mode.Qt is now configured for building. Just run 'make'.Once everything is built, you must run 'make install'.Qt will be installed into '/root/honglingfeng/arm-qt-5.12.8'.Prior to reconfiguration, make sure you remove any leftovers fromthe previous build.
QWebEngine基础依赖
sudo apt-get install bison flex gperf libdus* dbus* libfontconfig1-dev fontconfig libnss3-dev python2 pkg-config sudo apt-get install libicu-dev ninja-build
OpenGL相关依赖
sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev libegl1-mesa-dev freeglut* libgles* libglew*
xcb相关依赖
sudo apt-get install libx11-*sudo apt-get install libx11*sudo apt-get install libxcb-*sudo apt-get install libxcb*sudo apt-get install libxkbcommon-devsudosudo apt-get install libxkbcommon-x11-devsudo apt-get install libxcb-xinerama0-devsudo apt-get install libxcb-sync-dev
若报Could not find all necessary libraries for qpa-xcb support
建议再安装一遍依赖
sudo apt-get install bison build-essential gperf flex libasound2-dev\libcups2-dev libdrm-dev libegl1-mesa-dev libnss3-dev libpci-dev\libpulse-dev libudev-dev nodejs libxtst-dev gyp ninja-build\libssl-dev libxcursor-dev libxcomposite-dev libxrandr-dev
QtWebEngine库大部分问题都是没有依赖库导致的,如果出错就安装相关的依赖库即可。
编译
make -j4make install
这里要提一下QWebEngine使用了chromium-browser大部分功能,基本第三方库中的chromium都需要编译。rk3588板卡只有8g内存,需要添加10G swap虚拟内存空间来支持编译。不然容易编译中途因为内存耗尽而中断。
sudo mkdir /swapfilesudo dd if=/dev/zero of=swapfile bs=1G count=10sudo mkswap /swapfile# 开启sudo swapon /swapfile# 查看是否启用free -h #swap那一栏
遇到问题
build chromium错误WARNING: C++14 support is required in order to build chromium.WARNING: QtWebEngine will not be built.
可以通过安装chromium-brower解决
sudo apt updatesudo apt install chromium-browser
引用
1:【Qt编译】ARM环境 Qt5.14.2-QtWebEngine库编译 (完整版)https://blog.csdn.net/Monster_H7/article/details/137630448
2: 交叉编译 Qt5.12 armv8(aarch64) 带 WebEngine - NVIDIA JETSON TX2 https://www.cnblogs.com/zekexiao/p/17681933.html
3:【研究Qt webengine 模块编译】linux 交叉编译qt5.12的webengine模块成功的条件 https://liucjy.blog.csdn.net/article/details/104422691