当前位置:首页 » 《随便一记》 » 正文

【Qt编译】ARM环境 Qt5.14.2-QtWebEngine库编译 (完整版)

15 人参与  2024年05月07日 08:36  分类 : 《随便一记》  评论

点击全文阅读


ARM 编译Qt5.14.2源码

1.下载源码

下载Qt5.14.2源代码(可根据自己的需求下载不同版本)
在这里插入图片描述

下载网站:https://download.qt.io/new_archive/qt/5.14/5.14.2/single/

2.相关依赖(如果需要的话)

先参考官方文档的需求进行安装
官方安装依赖参考文档

2.1 QtWebEngine相关依赖

sudo apt-get install flex libicu-dev libxslt-devsudo apt-get install libssl-dev libxcursor-dev libxcomposite-dev libxdamage-dev libxrandr-dev sudo apt-get install libdus* dbus*sudo apt-get install libfontconfig1-dev fontconfig libcap-dev libxtst-dev libxext-devsudo apt-get install libpulse-dev libudev-dev libpci-dev libnss3-dev libasound2-dev libxss-dev sudo apt-get install libgstreamer-gl1.0-0 libgstreamer-plugins-base1.0-dev libgstreamer1.0-devsudo apt-get install libcups2* pulseaudio* alsa-* mesa-* systemd* system-* libgudev-1.0-dev libatspi2.0* at-spi2-* libclipper-devsudo apt-get install nodejs gyp ninja-build libdrm-dev

2.2 QtBase相关依赖

sudo apt-get install bison build-essential qt5-default sudo apt-get install perl git gperf ruby sudo apt-get install xcb* libxcb* libx11* libxkbcommon* libxrender* libxi-dev

2.3 QtOpenGL相关依赖

sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev libegl1-mesa-dev freeglut* libgles* libglew*

2.4 QtOpenGL相关依赖

sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev libegl1-mesa-dev freeglut* libgles* libglew*

备注
上述依赖尽可能安装,实际还需根据后面源码编译报错信息,根据报错缺少的依赖项进行补充安装

如果安装出现报错,可以尝试强制安装

#例如apt install gperf --fix-missing

3.编译源码

sudo tar -xvf qt-everywhere-src-5.14.2.tar.xz -C /opt/sudo touch auto.shsudo chmod 755 auto.shsudo vim auto.sh

3.1 当前目录下编写一个auto.sh文件,然后根据自己的情况,写入如下配置

./configure -prefix /home/book/qt-everywhere-src-5.14.2/arm-qt \-opensource \-confirm-license \-release \-strip \-shared \-optimized-qmake \-c++std c++11 \--rpath=no \-pch \-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 \-make libs \-make examples \-nomake tools -nomake tests \-gui \-widgets \-dbus-runtime \--glib=no \--iconv=no \--pcre=qt \--zlib=qt \-no-openssl \--freetype=qt \--harfbuzz=qt \-no-opengl \-linuxfb \--xcb=no \-tslib \--libpng=qt \--libjpeg=qt \--sqlite=qt \-plugin-sql-sqlite \-I/home/book/tslib/include \-L/home/book/tslib/lib \-recheck-all

··备注··

参数说明:-xplatform : 选择交叉编译时的目标(qtbase/mkspecs/目录中目标平台)-prefix:Qt最终安装到Arm板中的位置-extprefix:PC上交叉编译好的Qt的位置-hostprefix:编译出来给PC用的交叉编译工具存放的位置-verbose:打印配置过程中步骤信息-opensource:编译Qt的开源版本-confirm-license:自动确认许可-release:编译Qt的release版本-shared:构建 Qt 共享库,-static 静态库-make libs:编译 lib 组件-nomake tests:不编译 tests组件-nomake examples:不编译 examples 组件-skip ,跳过不需要的模块-no-opengl: 我在虚拟机下编译opengl模块报错,未解决 所以选择不编译

3.2执行脚本文件

sudo ./auto.shsudo make -j8sudo make install 

4.QtWebEngine编译遇到问题及解决

4.1 build chromium报错

WARNING: C++14 support is required in order to build chromium.WARNING: QtWebEngine will not be built.

首先,我个人的解决策略是安装一个chromium-browser

sudo apt updatesudo apt install chromium-browser

4.2 Qt WebEngine Build Tools 缺失补齐

Qt WebEngine Build Tools: Use System Ninja ....................... no Use System Gn .......................... no Jumbo Build Merge Limit ................ 8 Developer build ........................ no QtWebEngine required system libraries: fontconfig ........................... no dbus ................................. no nss .................................. no khr .................................. yes glibc ................................ yes

经过查询并安装,需要安装一些系统库才能成功构建 Qt WebEngine 模块。这些系统库通常是 Qt WebEngine 所依赖的外部库,缺少其中任何一个都可能导致构建失败。根据输出,你需要安装以下系统库:

fontconfig: 字体配置库,用于处理字体相关的任务。dbus: D-Bus 是 Linux 桌面应用程序之间进行通信的消息总线系统。nss(Network Security Services): 用于支持网络安全的库。khr: 应该是指 Khronos Group 的相关库,可能与 OpenGL 或 Vulkan 相关。glibc: GNU C 库,是 Linux 系统中的标准 C 库。
#确保安装了这些库的开发包,以便在构建 Qt WebEngine 时能够找到相应的头文件和链接库。你可以使用你的发行版的包管理器来安装这些库的开发包,例如在 Ubuntu 上可以使用 apt 进行安装:sudo apt install libfontconfig1-dev libdbus-1-dev libnss3-dev libgl1-mesa-dev

4.3 gperf依赖缺失报错

如有一下报错:
在这里插入图片描述

sudo apt install gperf#安装完成之后查看 gperf --version 查看版本信息

如果上述依赖问题都解决,执行auto.sh脚本编译报依赖缺失,请**清除缓存**

4.4 缺少qtlocation.so 错误印象无法编译

在这里插入图片描述

#auto.sh 脚本中不能 -skip qtlocation进入到/opt/qt-everywhere-src-5.14.2/qtlocation/ 目录中, 进行编译qtlocationsudo make -j8sudo make install

4.5 ld报错 undefined reference to 'ff_h264_xxx’错误

在这里插入图片描述

安装ffmpeg 以及相关依赖

#如果想要添加libwebp ffmpeg opus 等支持还需要运行sudo apt install libavdevice-dev libavcodec-dev libopus-dev libwebp-dev ffmpeg

4.6 ERROR: Feature ‘xcb’ was enabled, but the pre-condition ‘features.thread && features.xkbcommon && libs.xcb’ failed

静态编译前安装一下包

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

再安装一遍依赖

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

4.8 ERROR: A pkg-config support is required to build QtWebEngine.

删除config.cache后执行sudo apt-get install pkg-config

4.9 ERROR: khronos development headers appear to be missing (mesa/libegl1-mesa-dev)

sudo apt-get install libegl1-mesa-dev

4.10 ERROR: A suitable version of nss could not be found.

sudo apt-get install libnss3-dev

4.11 ERROR: A suitable version of dbus could not be found.

sudo apt-get install dbussudo apt-get install dbus-testssudo apt-get install libdbus-glib-1-dev

4.12 ERROR: A suitable version of fontconfig could not be found

sudo apt install libfontconfig1-dev -y

4.13 ERROR: Could not find all necessary libraries for qpa-xcb support

sudo apt install libxcursor-devsudo apt install libxcomposite-devsudo apt install libdrm-devsudo apt install libxtst-dev -y

4.14 编译过程中报错/3rdparty/chromium/third_party/webrtc/modules/desktop_capture/linux/screen_capturer_x11.h:16:10: fatal error: X11/extensions/Xdamage.h: No such file or directory

sudo apt-get install flex libicu-dev libxslt-devsudo apt-get install libssl-dev libxcursor-dev libxcomposite-dev libxdamage-dev libxrandr-dev

5. 删除缓存,然后重新执行auto.sh 脚本编译

sudo rm config.cache

避免反复报没有gperf等依赖错误 如果还报错,则将gperf 添加到PATH环境变量中

#我的 gperf 默认安装路径 /usr/bin/gperf#which gperf 可以查看export PATH="$PATH:/usr/bin/gperf"

6.编译出来的环境查询

6.1 使用的编译脚本auto.sh

./configure \        -prefix /opt/jetson/Qt5.14.2 \        -xplatform linux-aarch64-gnu-g++ \         -opensource \        -confirm-license \        -nomake examples \        -nomake tests \        -release \        -webengine-proprietary-codecs \        -skip qtmultimedia \        -skip qt3d \        -skip qtactiveqt \        -skip qtandroidextras \        -skip qtcanvas3d \        -skip qtconnectivity \        -skip qtdatavis3d \        -skip qtdoc \        -skip qtgamepad \        -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 \        -opengl es2 \        -xcb \        -xcb-xlib \        -egl \        -eglfs \        --pcre=qt

6.2 切换的镜像源 /etc/apt/source.list (20.04 ubuntu & 中科大)

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to# newer versions of the distribution.deb http://ports.ubuntu.com/ubuntu-ports/ focal main restricted# deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted## Major bug fix updates produced after the final release of the## distribution.deb http://ports.ubuntu.com/ubuntu-ports/ focal-updates main restricted# deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu## team. Also, please note that software in universe WILL NOT receive any## review or updates from the Ubuntu security team.deb http://ports.ubuntu.com/ubuntu-ports/ focal universe# deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic universedeb http://ports.ubuntu.com/ubuntu-ports/ focal-updates universe# deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-updates universe## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu## team, and may not be under a free licence. Please satisfy yourself as to## your rights to use the software. Also, please note that software in## multiverse WILL NOT receive any review or updates from the Ubuntu## security team.deb http://ports.ubuntu.com/ubuntu-ports/ focal multiverse# deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic multiversedeb http://ports.ubuntu.com/ubuntu-ports/ focal-updates multiverse# deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-updates multiverse## N.B. software from this repository may not have been tested as## extensively as that contained in the main release, although it includes## newer versions of some applications which may provide useful features.## Also, please note that software in backports WILL NOT receive any review## or updates from the Ubuntu security team.deb http://ports.ubuntu.com/ubuntu-ports/ focal-backports main restricted universe multiverse# deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted universe multiverse## Uncomment the following two lines to add software from Canonical's## 'partner' repository.## This software is not part of Ubuntu, but is offered by Canonical and the## respective vendors as a service to Ubuntu users.# deb http://archive.canonical.com/ubuntu bionic partner# deb-src http://archive.canonical.com/ubuntu bionic partnerdeb http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted# deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricteddeb http://ports.ubuntu.com/ubuntu-ports/ focal-security universe# deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-security universedeb http://ports.ubuntu.com/ubuntu-ports/ focal-security multiverse# deb-src http://ports.ubuntu.com/ubuntu-ports/ bionic-security multiverse
deb https://mirrors.ustc.edu.cn/ubuntu-ports/ focal main restricted universe multiversedeb-src https://mirrors.ustc.edu.cn/ubuntu-ports/ focal main restricted universe multiversedeb https://mirrors.ustc.edu.cn/ubuntu-ports/ focal-updates main restricted universe multiversedeb-src https://mirrors.ustc.edu.cn/ubuntu-ports/ focal-updates main restricted universe multiversedeb https://mirrors.ustc.edu.cn/ubuntu-ports/ focal-backports main restricted universe multiversedeb-src https://mirrors.ustc.edu.cn/ubuntu-ports/ focal-backports main restricted universe multiversedeb https://mirrors.ustc.edu.cn/ubuntu-ports/ focal-security main restricted universe multiversedeb-src https://mirrors.ustc.edu.cn/ubuntu-ports/ focal-security main restricted universe multiversedeb https://mirrors.ustc.edu.cn/ubuntu-ports/ focal-proposed main restricted universe multiversedeb-src https://mirrors.ustc.edu.cn/ubuntu-ports/ focal-proposed main restricted universe multiverse

最后: 如有描述错误的地方或者网友遇到的坑,请评论联系我更正及补充,特此将自己个人两天编译遇到的问题分享给大家,协助大家更好地部署环境。

参考:

参考:
【1】./configure参数解释(最新版本)

【2】编译QWebEngine 安装所需依赖


点击全文阅读


本文链接:http://m.zhangshiyu.com/post/104445.html

<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于我们 | 我要投稿 | 免责申明

Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1