资料收集:
onvif获取rtsp地址流程
1.搜索Probe,设备发现,发现IPC,获取webService地址;
2.获取能力集,GetCapabilities,从中识别出媒体信息地址URI:http://192.168.73.231:8080/onvif/media_service
3.获取媒体信息,GetProfiles,获取媒体信息文件,识别主通道、子通道的视频编码分辨率
4.获取RTSP地址,GetStreamUri,获取指定通道的流媒体地址

链接:https://www.jianshu.com/p/03be66706c22

使用github.com/use-go/onvif包,实现go语言对接onvif协议

利用gSoap生成ONVIF Server框架

服务器端 UDP socket,监听239.255.255.250:3702

IPC工作原理:
首先,进程A获取来自AR0330摄像头模块的YUV原始视频图像,并使用H265压缩编码算法进行压缩编码获 得H265格式码流,该过程通过使用海思提供的媒体处理平台(MPP)实现;

其次,进程B负责响应网络客户端的请求,将进程A的输出码流通过千兆以太网接 口实时地发送出去,该过程通过对LIVE555开源代码(该代码原本只支持文件发送功能,而不支持内存实时数据发送功能)二次开发实现;
整体流程:

Probe: 发现网络摄像头,获取webserver地址 http://192.168.15.240/onvif/device_service

GetCapabilities:获取设备能力文件,从中识别出媒体信息地址URI: http://192.168.15.240/onvif/Media

GetProfiles: 获取媒体信息文件,识别主通道、子通道的视频编码分辨率

GetStreamUri:获取指定通道的流媒体地址 rtsp://192.168.15.240:554/Streaming/Channels/2?transportmode=unicast

onvif 设备发现的机制
从ONVIF的官方文档中可以了解到,客户端在UDP协议下,向网段内的组播地址239.255.255.250,端口3702,不断地向四周发送Probe消息探针,而网段内的服务器在接收到Probe这个探测消息后,通过回复ProbeMatch消息让客户端接收,从而让客户端识别到服务器。

所以服务器端就需要创建一个UDP协议的socket,去监听239.255.255.250:3702,接收到客户端的Probe探针后,进行响应,从而让客户端识别到onvif服务器。
Referenced from:https://blog.csdn.net/weixin_44362642/article/details/86750172

通过抓包,发现probe的包内容
通过udp工具发送出去也是可以的.

<?xml version="1.0" encoding="utf-8"?><Envelope xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns="http://www.w3.org/2003/05/soap-envelope"><Header><wsa:MessageID xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">uuid:cb9529cf-0a34-4971-b140-b5510c22d820</wsa:MessageID><wsa:To xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">urn:schemas-xmlsoap-org:ws:2005:04:discovery</wsa:To><wsa:Action xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</wsa:Action></Header><Body><Probe xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/ws/2005/04/discovery"><Types>tds:Device</Types><Scopes /></Probe></Body></Envelope><?xml version="1.0" encoding="utf-8"?><Envelope xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns="http://www.w3.org/2003/05/soap-envelope"><Header><wsa:MessageID xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">uuid:f5dfce18-8fb2-4a64-a680-3051a2e7970b</wsa:MessageID><wsa:To xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">urn:schemas-xmlsoap-org:ws:2005:04:discovery</wsa:To><wsa:Action xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</wsa:Action></Header><Body><Probe xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/ws/2005/04/discovery"><Types>dn:NetworkVideoTransmitter</Types><Scopes /></Probe></Body></Envelope>

应答示例:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:ns4="http://www.onvif.org/ver10/pacs" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:ns1="http://www.onvif.org/ver20/media/wsdl" xmlns:ns2="http://www.onvif.org/ver10/actionengine/wsdl" xmlns:ns3="http://www.onvif.org/ver10/accesscontrol/wsdl" xmlns:ns5="http://www.onvif.org/ver10/doorcontrol/wsdl" xmlns:ns6="http://www.onvif.org/ver10/advancedsecurity/wsdl" xmlns:ns7="http://www.onvif.org/ver10/accessrules/wsdl" xmlns:ns8="http://www.onvif.org/ver10/credential/wsdl" xmlns:ns9="http://www.onvif.org/ver10/schedule/wsdl" xmlns:tad="http://www.onvif.org/ver10/analyticsdevice/wsdl" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tls="http://www.onvif.org/ver10/display/wsdl" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trc="http://www.onvif.org/ver10/recording/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:trv="http://www.onvif.org/ver10/receiver/wsdl" xmlns:tse="http://www.onvif.org/ver10/search/wsdl"><SOAP-ENV:Header><wsa:MessageID>urn:uuid:ed2e0d23-207e-4211-85a0-a47c184ce6cb</wsa:MessageID><wsa:RelatesTo>uuid:cb9529cf-0a34-4971-b140-b5510c22d820</wsa:RelatesTo><wsa:To SOAP-ENV:mustUnderstand="true">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To><wsa:Action SOAP-ENV:mustUnderstand="true">http://schemas.xmlsoap.org/ws/2005/04/discovery/ProbeMatches</wsa:Action><wsdd:AppSequence MessageNumber="3" InstanceId="0"></wsdd:AppSequence></SOAP-ENV:Header><SOAP-ENV:Body><wsdd:ProbeMatches><wsdd:ProbeMatch><wsa:EndpointReference><wsa:Address>urn:uuid:4d474e6d-4e44-4131-5a6a-4d7a4d574e68</wsa:Address></wsa:EndpointReference><wsdd:Types>tdn:NetworkVideoTransmitter</wsdd:Types><wsdd:Scopes>onvif://www.onvif.org/Profile/Streaming onvif://www.onvif.org/location/city/Nanning onvif://www.onvif.org/location/street/Binhe onvif://www.onvif.org/location/floor/19 onvif://www.onvif.org/hardware/PCC300V8E onvif://www.onvif.org/name/CAMERA </wsdd:Scopes><wsdd:XAddrs>http://192.168.2.79:8080/onvif/device_service</wsdd:XAddrs><wsdd:MetadataVersion>1</wsdd:MetadataVersion></wsdd:ProbeMatch></wsdd:ProbeMatches></SOAP-ENV:Body></SOAP-ENV:Envelope>

sudo apt update
sudo apt install build-essential clang
sudo apt install qtcreator qtbase5-dev qt5-qmake cmake
sudo apt install qtwebengine5-dev qtmultimedia5-dev
sudo apt install git
sudo apt-get install open-vm-tools-desktop
git config --global http.sslVerify false

qmake -v

Using Qt version 5.15.3 in /usr/lib/x86_64-linux-gnu

配置webrtc相关

sudo apt install libqt5webengine5 
sudo apt install libqt5webenginewidgets5
sudo apt install libqt5multimediawidgets5

增加权限相关的控制,增加自签名证书的错误忽略.

#include <QApplication>
#include <QUrl>
#include <QWebEngineView>
#include <QWebEnginePage>
#include <QWebEngineCertificateError>

class WebEnginePage: public QWebEnginePage{
    Q_OBJECT
public:
    WebEnginePage(QObject *parent = Q_NULLPTR):QWebEnginePage(parent){
        connect(this, &WebEnginePage::featurePermissionRequested, this, &WebEnginePage::onFeaturePermissionRequested);
    }
private Q_SLOTS:
    void onFeaturePermissionRequested(const QUrl &securityOrigin, QWebEnginePage::Feature feature){

        if(feature  == QWebEnginePage::MediaAudioCapture
                || feature == QWebEnginePage::MediaVideoCapture
                || feature == QWebEnginePage::MediaAudioVideoCapture)
            setFeaturePermission(securityOrigin, feature, QWebEnginePage::PermissionGrantedByUser);
        else
            setFeaturePermission(securityOrigin, feature, QWebEnginePage::PermissionDeniedByUser);
    }
protected:
    bool certificateError(const QWebEngineCertificateError &error){
        return error.isOverridable();
    }
};

下载源代码:

wget https://mirrors.tuna.tsinghua.edu.cn/qt/archive/qt/5.15/5.15.3/single/qt-everywhere-opensource-src-5.15.3.tar.xz

解压缩:

tar xvf qt-everywhere-opensource-src-5.15.3.tar.xz -C ~/opt

cd ~/opt/qt-everywhere-opensource-src-5.15.3

./configure -prefix  ~/opt/qt5.15.3-x64  -release -opensource -confirm-license -static -shared -platform linux-g++ -qt-freetype -no-pch -no-avx -no-openssl -no-cups -no-dbus -no-opengl -no-glib -no-xcb -no-eglfs -no-pkg-config -no-iconv -skip qtwebchannel -skip qtcanvas3d

可能会出现错误

/qt-everywhere-src-5.15.3/qtbase/src/corelib/text/qbytearraymatcher.h:105:38:error: ‘numeric_limits’ is not a member of ‘std’
105 | const auto uchar_max = (std::numeric_limits<uchar>::max)();

修改~/opt/qt-everywhere-src-5.15.3/qtbase/src/corelib/text/qbytearray.h
添加
#include <limits>

再次运行configure

make

出现错误:
gcc: error: unrecognized command line option ‘-mshstk’; did you mean ‘-msha’?

使用Ubuntu 20 编译 aarch64 版本的QT

编译命令

sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu build-essential
tar xvf qt-everywhere-opensource-src-5.15.9.tar.xz
cd qt-everywhere-opensource-src-5.15.9
mkdir build
cd build/

../configure -prefix /opt/aarch64 -make libs -xplatform linux-aarch64-gnu-g++ -no-opengl
make -j2
sudo make install

然后就将相应的库安装到/opt/aarch64目录下面了.

Ubuntu编译OpenGL程序示例
之所以在这里引入OpenGL,是因为,咱们在编译QT的时候,没有编译opengl,如果这里可以成功,我们可以使用sysroot的方式引入opengl库,从而交叉编译成功支持opengl的qt库.

sudo apt update
sudo apt install libglu1-mesa-dev freeglut3-dev mesa-common-dev
vi main.cpp

程序源代码:

#include <GL/glut.h>
void displayMe(void)
{
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_POLYGON);
        glVertex3f(0.5, 0.0, 0.5);
        glVertex3f(0.5, 0.0, 0.0);
        glVertex3f(0.0, 0.5, 0.0);
        glVertex3f(0.0, 0.0, 0.5);
    glEnd();
    glFlush();
}

int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE);
    glutInitWindowSize(400, 300);
    glutInitWindowPosition(100, 100);
    glutCreateWindow("Hello world!");
    glutDisplayFunc(displayMe);
    glutMainLoop();
    return 0;
}

编译命令:

g++ main.cpp -o firstOpenGlApp -lglut -lGLU -lGL
./firstOpenGlApp

运行效果:
截图 2023-11-21 09-23-47.png
Qt5.15就不支持下载安装包了,只能自己编译或者apt安装了.最后的下载地址:
https://download.qt.io/archive/qt/5.14/5.14.2/

sudo apt install qt5-default qtcreator qtwebengine5-dev qtmultimedia5-dev

Ubuntu Qt交叉编译环境的搭建

经过测试,发现并没有编译qtwebengin,检查发现,还需要其他一些东西

sudo apt install gperf bison flex python2 nodejs

后面又安装了libclang-dev

安装完这些东西后,又提示没有指定sysroot,所以不能够编译webengine.哪就来指定sysroot吧.在本机的设备机上都安装rsync
sudo apt install rsync

然后在虚拟机上,创建sysroot目录
mkdir -p ~/sysroot/usr
mkdir -p ~/sysroot/lib
cd ~
rsync -avz --rsync-path="rsync" --delete root@192.168.4.202:/lib sysroot/lib
rsync -avz --rsync-path="rsync" --delete root@192.168.4.202:/usr/include sysroot/usr
rsync -avz --rsync-path="rsync" --delete root@192.168.4.202:/usr/lib sysroot/usr

根据实际ip,修改上面的192.168.4.202,注意第一行,可能要修改一下,因为原来的/lib目录就是一个软链接,所以在sysroot/lib里面要相应修改一下.

修改configure命令

PKG_CONFIG_LIBDIR=/home/hesy/sysroot/usr/lib/aarch64-linux-gnu/pkgconfig ../configure -prefix /opt/aarch64 -make libs -xplatform linux-aarch64-gnu-g++ -sysroot /home/hesy/sysroot -webengine-webrtc

现在只有一个警告了.No wayland-egl support detected

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

Note: PKG_CONFIG_SYSROOT_DIR automatically set to /home/hesy/sysroot

Note: No wayland-egl support detected. Cross-toolkit compatibility disabled.

Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into '/home/hesy/sysroot/opt/aarch64'.

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

查看webengine相关的选项, 发现alsa, pulseaudio等都没有编译,这个应该要加进去.
./configure -h |grep webengine

-webengine-alsa -webengine-pulseaudio -system-ffmpeg -webengine-opus -webengine-webp

另外,好像SSL也没有编译进去,也需要打开.使用--openssl-linked加上OPENSSL_LIBS二个选项就可以打开ssl了.

不知道改了什么,反正用下面这个就好了.有可能改了sysroot/lib的软链接出来.

OPENSSL_LIBS='-L/home/hesy/sysroot/usr/lib/aarch64-linux-gnu -lssl -lcrypto'  PKG_CONFIG_LIBDIR=/home/hesy/sysroot/usr/lib/aarch64-linux-gnu/pkgconfig ../configure -prefix /opt/aarch64 -make libs -xplatform linux-aarch64-gnu-g++ -sysroot /home/hesy/sysroot -webengine-webrtc  -webengine-pulseaudio -qt-ffmpeg -qt-opus -qt-webp -openssl-linked -I/home/hesy/sysroot/usr/include -L/home/hesy/sysroot/usr/lib/aarch64-linux-gnu

提示信息如下:
Note: Also available for Linux: linux-clang linux-icc

Note: PKG_CONFIG_SYSROOT_DIR automatically set to /home/hesy/sysroot

Note: No wayland-egl support detected. Cross-toolkit compatibility disabled.
直接忽略掉了.
make 试下

中间遇到undefined reference to _dl_stack_flags之类的错误,发现sysroot/lib/里面的libpthread.so的软链接路径不对,导致直接链接的是libpthread.a静态库,所以报了这个错误.

出现错误:
error: static assertion failed: Required feature library for file /home/hesy/qt5/qtbase/include/QtCore/../../src/corelib/plugin/qlibrary.h not available.
121 | # define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message)

在排查上面的问题的时候,发现了sysroot/lib目录下有很多软连接不正确,顺带修改一下.
ln -snf libBrokenLocale.so.1 libBrokenLocale.so

使用Qt5.12.9来编译,还是会出现这个错误,感觉像是openssl的问题.但不确定.

再换Qt5.15.11来编译验证.

之所以这么试,是看到网上有人说,重新解压源码来编译就没问题了.

试了下下,果然编译通过了.不明觉厉.

make install

出现错误:
cannot find -lqt_clip2tri

重新编译,出现错误:
fatal error: wayland-client.h: No such file or directory
26 | #include <wayland-client.h>

安装相应的包
sudo apt install -y libwayland-dev
重新编译,出现错误
undefined reference to `__pointer_chk_guard_local'

检查发现,又是链接了libthread.a静态库的原因,软连接坏了,修复一下.
ln -snf libz.so.1.2.11 libz.so
ln -snf libuuid.so.1.3.0 libuuid.so
ln -snf libutil.so.1 libutil.so
ln -snf libtinfo.so.6 libtinfo.so
ln -snf libtiff.so.5.5.0 libtiff.so
ln -snf libsepol.so.1 libsepol.so
ln -snf libselinux.so.1 libselinux.so
ln -snf librt.so.1 librt.so
ln -snf libresolv.so.2 libresolv.so
ln -snf libpcre.so.3 libpcre.so
ln -snf libnss_nisplus.so.2 libnss_nisplus.so
ln -snf libnss_nis.so.2 libnss_nis.so
ln -snf libnss_hesiod.so.2 libnss_hesiod.so
ln -snf libnss_files.so.2 libnss_files.so
ln -snf libnss_dns.so.2 libnss_dns.so
ln -snf libnss_compat.so.2 libnss_compat.so
ln -snf libnsl.so.1 libnsl.so
ln -snf libmount.so.1.1.0 libmount.so
ln -snf libexpat.so.1.6.11 libexpat.so
ln -snf libdl.so.2 libdl.so
ln -snf libdbus-1.so.3.19.11 libdbus-1.so
ln -snf libblkid.so.1.1.0 libblkid.so
ln -snf libanl.so.1 libanl.so
ln -snf libBrokenLocale.so.1 libBrokenLocale.so
ln -snf libcrypt.so.1.1.0 libcrypt.so
ln -snf libm.so.6 libm.so
ln -snf libpthread.so.0 libpthread.so
ln -snf libthread_db.so.1 libthread_db.so

重新编译.

出现错误:
ERROR at //build/config/linux/pkg_config.gni:103:17: Script returned non-zero exit code.
Package nss was not found in the pkg-config search path.
Perhaps you should add the directory containing `nss.pc'
to the PKG_CONFIG_PATH environment variable
No package 'nss' found

错误应该是由这个python脚本引起的
/usr/bin/python2 /home/hesy/qt5/qt-everywhere-src-5.15.11/qtwebengine/src/3rdparty/chromium/build/config/linux/pkg-config.py -p /usr/bin/pkg-config nss -v -lssl3
Package nss was not found in the pkg-config search path.
Perhaps you should add the directory containing `nss.pc'
to the PKG_CONFIG_PATH environment variable
No package 'nss' found
Could not run pkg-config.
执行命令
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/hesy/sysroot/usr/lib/pkgconfig
/usr/bin/python2 /home/hesy/qt5/qt-everywhere-src-5.15.11/qtwebengine/src/3rdparty/chromium/build/config/linux/pkg-config.py -p /usr/bin/pkg-config nss -v -lssl3
[["/usr/include/nss", "/usr/include/nspr"], [], ["nss3", "nssutil3", "smime3", "plds4", "plc4", "nspr4"], ["/usr/lib/aarch64-linux-gnu"]]

然后继续make

出现错误:
ninja: build stopped: subcommand failed.
make[4]: * [Makefile.gn_run:1131: run_ninja] Error 1
向上查找,发现是这句出错了.
[2696/24109] /usr/bin/python2 ../../../../../qtwebengine/src/3rdparty/chromium/third_party/catapult/tracing/bin/generate_about_tracing_contents --outdir gen/content/browser/tracing
FAILED: gen/content/browser/tracing/about_tracing.js gen/content/browser/tracing/about_tracing.html

编辑修改文件 /home/hesy/qt5/qt-everywhere-src-5.15.11/qtwebengine/src/3rdparty/chromium/third_party/catapult/tracing/tracing_build/generate_about_tracing_contents.py
change defualt=False to default=True in line 19.
参考( https://forum.qt.io/topic/137881/qt-5-15-5-compilation-failure-on-ubuntu-22-04-failed-gen-content-browser-tracing-about_tracing-js-gen-content-browser-tracing-about_tracing-html/4 )

编译到后期的时候,会出现资源不够用情况,使用命令禁用一些cpu核心,来保证编译正常运行.

For example, if you have a 12 core and 16 GB RAM, you can disable last 6 core with:

sudo chcpu --disable 6-11

And start make process which will be execute ninja later. In this setup ninja is going to use total of 8 parallel jobs (6+2). After a while (lets say 30 seconds), you can enable the cpus like below:

sudo chcpu --enable 6-11

to continue working while QtWebEngine build running.

使用了上面的办法,还是老是死机,没办法了,修改ninja.cc源码,将进程数据+2直接改为-1

重新configure

OPENSSL_LIBS='-L/home/hesy/sysroot/usr/lib/aarch64-linux-gnu -lssl -lcrypto'  PKG_CONFIG_LIBDIR=/home/hesy/sysroot/usr/lib/aarch64-linux-gnu/pkgconfig ../configure -prefix /opt/aarch64 -make libs -xplatform linux-aarch64-gnu-g++ -sysroot /home/hesy/sysroot -webengine-webrtc  -webengine-pulseaudio -qt-ffmpeg -qt-opus -qt-webp -openssl-linked -I/home/hesy/sysroot/usr/include -L/home/hesy/sysroot/usr/lib/aarch64-linux-gnu

Qt will be installed into '/home/hesy/sysroot/opt/aarch64'.

8:53开始编译
3个小时左右能够编译完成.

运行的时候报缺少qba-xcb的错误.

xcb/xcb_keysyms.h

apt-file search "xcb/xcb_keysyms.h"

sudo apt install libxcb-keysyms1-dev

每次更新后,要重新删除临时文件,重新configure才能够找到相应的头文件.

xcb/randr.h not found in [] and global paths.

apt-file search "xcb/randr.h"

libxcb-randr0-dev: /usr/include/xcb/randr.h

apt install libxcb-randr0-dev

xcb/xcb_renderutil.h not found in [] and global paths.

apt-file search "xcb/xcb_renderutil.h"

libxcb-render-util0-dev: /usr/include/xcb/xcb_renderutil.h

apt install libxcb-render-util0-dev

xcb/shape.h not found in [] and global paths.

apt-file search "xcb/shape.h"

libxcb-shape0-dev: /usr/include/xcb/shape.h

apt install libxcb-shape0-dev

xcb/sync.h not found in [] and global paths.

apt-file search "xcb/sync.h"

libxcb-sync-dev: /usr/include/xcb/sync.h

apt install libxcb-sync-dev

xcb/xfixes.h not found in [] and global paths.

apt-file search "xcb/xfixes.h"

libxcb-xfixes0-dev: /usr/include/xcb/xfixes.h

apt install libxcb-xfixes0-dev
apt install libxcb*-dev

终于可以使用了,直接make -j4,然后就是慢慢的等.
最新的configure命令如下:

OPENSSL_LIBS='-L/home/hesy/sysroot/usr/lib/aarch64-linux-gnu -lssl -lcrypto'  PKG_CONFIG_LIBDIR=/home/hesy/sysroot/usr/lib/aarch64-linux-gnu/pkgconfig ../configure -prefix /opt/aarch64 -make libs -xplatform linux-aarch64-gnu-g++ -sysroot /home/hesy/sysroot -webengine-webrtc  -webengine-pulseaudio -qt-ffmpeg -qt-opus -qt-webp -openssl-linked -I/home/hesy/sysroot/usr/include -L/home/hesy/sysroot/usr/lib/aarch64-linux-gnu -xcb -qpa xcb

qtwebengine不能播放mp4的问题.

[1093:1112:1127/003829.439019:ERROR:batching_media_log.cc(26)] MediaEvent: MEDIA_ERROR_LOG_ENTRY {"error":"FFmpegDemuxer: no supported streams"}
[1093:1093:1127/003829.439757:ERROR:batching_media_log.cc(26)] MediaEvent: PIPELINE_ERROR DEMUXER_ERROR_NO_SUPPORTED_STREAMS

上面的操作始终都不能够编译成功qtwebengine带qpa-xcb,重新来一次.
查看qt5.15的系统依赖. https://doc.qt.io/qt-5.15/linux-requirements.html
在ubuntu20.04上安装下面包

sudo apt install libfontconfig1-dev libfreetype6-dev libx11-dev libx11-xcb-dev libxext-dev libxfixes-dev libxi-dev libxrender-dev libxcb1-dev libxcb-glx0-dev libxcb-keysyms1-dev libxcb-image0-dev libxcb-shm0-dev libxcb-icccm4-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-render-util0-dev libxcb-xinerama0-dev libxkbcommon-dev libxkbcommon-x11-dev libatspi2.0-dev

sudo apt install libxcomposite-dev libdrm-dev libxcursor-dev libxi-dev libxrandr-dev libxtst-dev libxdamage-dev libxss-dev libxkbfile-dev

sudo apt install libavcodec-dev libavformat-dev libavutil-dev
sudo apt install libopus-dev libwebp-dev libvpx-dev

执行了这些安装包后,使用configure是能够把qtwebengine给包进去了.

最简单的configure

../configure -opensource -confirm-license -webengine-ffmpeg
make -j5 

9:21开始编译,看看有没有什么问题.

通过将/usr/share/pkgconifg的*.pc文件复制到/usr/lib/pkgconfig目录后,可以交叉编译了.

OPENSSL_LIBS='-L/home/hesy/sysroot/usr/lib/aarch64-linux-gnu -lssl -lcrypto'  PKG_CONFIG_LIBDIR=/home/hesy/sysroot/usr/lib/aarch64-linux-gnu/pkgconfig ../configure -prefix /opt/aarch64 -make libs -xplatform linux-aarch64-gnu-g++ -sysroot /home/hesy/sysroot -webengine-webrtc  -webengine-pulseaudio -no-eglfs -recheck-all -webengine-opus -webengine-ffmpeg -webengine-proprietary-codecs -openssl-linked -I/home/hesy/sysroot/usr/include -L/home/hesy/sysroot/usr/lib/aarch64-linux-gnu 

上面的命令是可以正确配置的,试下下面这个.

../configure -prefix /opt/aarch64 -make libs -xplatform linux-aarch64-gnu-g++ -sysroot /home/hesy/sysroot -webengine-webrtc  -webengine-pulseaudio -no-eglfs -recheck-all -webengine-opus -webengine-ffmpeg -webengine-proprietary-codecs -opensource -confirm-license

经过验证,直接使用上面的命令就可以配置成功了.剩下的就是几个小时的编译了.

配置后输出信息汇总如下:

Configure summary:

Building on: linux-g++ (x86_64, CPU features: mmx sse sse2)
Building for: linux-aarch64-gnu-g++ (arm64, CPU features: cx16 neon)
Target compiler: gcc 9.4.0
Configuration: cross_compile compile_examples enable_new_dtags largefile neon precompile_header shared shared rpath release c++11 c++14 c++17 c++1z concurrent dbus reduce_exports stl
Build options:
  Mode ................................... release
  Optimize release build for size ........ no
  Building shared libraries .............. yes
  Using C standard ....................... C11
  Using C++ standard ..................... C++17
  Using ccache ........................... no
  Using new DTAGS ........................ yes
  Relocatable ............................ yes
  Using precompiled headers .............. yes
  Using LTCG ............................. no
  Target compiler supports:
    NEON ................................. 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 ................................... no
  Using system zlib ...................... yes
  Zstandard support ...................... no
Qt Core:
  DoubleConversion ....................... yes
    Using system DoubleConversion ........ no
  GLib ................................... yes
  iconv .................................. yes
  ICU .................................... no
  Built-in copy of the MIME database ..... yes
  Tracing backend ........................ <none>
  Logging backends:
    journald ............................. no
    syslog ............................... no
    slog2 ................................ no
  PCRE2 .................................. yes
    Using system PCRE2 ................... yes
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
  OCSP-stapling .......................... yes
  SCTP ................................... no
  Use system proxies ..................... yes
  GSSAPI ................................. no
Qt Gui:
  Accessibility .......................... yes
  FreeType ............................... yes
    Using system FreeType ................ yes
  HarfBuzz ............................... yes
    Using system HarfBuzz ................ no
  Fontconfig ............................. yes
  Image formats:
    GIF .................................. yes
    ICO .................................. yes
    JPEG ................................. yes
      Using system libjpeg ............... no
    PNG .................................. yes
      Using system libpng ................ yes
  Text formats:
    HtmlParser ........................... yes
    CssParser ............................ yes
    OdfWriter ............................ yes
    MarkdownReader ....................... yes
      Using system libmd4c ............... no
    MarkdownWriter ....................... 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 ................................. yes
  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
    xkbcommon-x11 ........................ yes
QPA backends:
  DirectFB ............................... no
  EGLFS .................................. no
  LinuxFB ................................ yes
  VNC .................................... yes
  XCB:
    Using system-provided xcb-xinput ..... no
    Native painting (experimental) ....... no
    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 ............................. yes
  SQLite2 ................................ no
  SQLite ................................. yes
    Using system provided SQLite ......... no
  TDS (Sybase) ........................... yes
Qt Testlib:
  Tester for item models ................. yes
Serial Port:
  ntddmodm ............................... no
Qt SerialBus:
  Socket CAN ............................. yes
  Socket CAN FD .......................... yes
  SerialPort Support ..................... yes
Further Image Formats:
  JasPer ................................. no
  MNG .................................... no
  TIFF ................................... yes
    Using system libtiff ................. no
  WEBP ................................... yes
    Using system libwebp ................. yes
Qt QML:
  QML network support .................... yes
  QML debugging and profiling support .... yes
  QML just-in-time compiler .............. yes
  QML sequence object .................... yes
  QML XML http request ................... yes
  QML Locale ............................. yes
Qt QML Models:
  QML list model ......................... 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
QtQuick3D:
  Assimp ................................. yes
  System Assimp .......................... no
Qt Scxml:
  ECMAScript data model for QtScxml ...... yes
Qt Gamepad:
  SDL2 ................................... no
Qt 3D:
  Assimp ................................. yes
  System Assimp .......................... no
  Output Qt3D GL traces .................. no
  Use SSE2 instructions .................. no
  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
  RHI Renderer ........................... no
Qt 3D GeometryLoaders:
  Autodesk FBX ........................... no
Qt Wayland Client ........................ no
Qt Wayland Compositor .................... no
Qt Bluetooth:
  BlueZ .................................. no
  BlueZ Low Energy ....................... no
  Linux Crypto API ....................... no
  Native Win32 Bluetooth ................. no
  WinRT Bluetooth API (desktop & UWP) .... no
  WinRT advanced bluetooth low energy 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 . no
  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 .......................... yes
  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 TextToSpeech:
  Flite .................................. no
  Flite with ALSA ........................ no
  Speech Dispatcher ...................... no
Qt Tools:
  Qt Assistant ........................... yes
  Qt Designer ............................ yes
  Qt Distance Field Generator ............ yes
  kmap2qmap .............................. yes
  Qt Linguist ............................ yes
  Mac Deployment Tool .................... no
  makeqpf ................................ yes
  pixeltool .............................. yes
  qdbus .................................. yes
  qev .................................... yes
  Qt Attributions Scanner ................ yes
  qtdiag ................................. yes
  qtpaths ................................ yes
  qtplugininfo ........................... yes
  Windows deployment tool ................ no
  WinRT Runner Tool ...................... no
Qt Tools:
  QDoc ................................... yes
Qt WebEngine Build Tools:
  Use System Ninja ....................... yes
  Jumbo Build Merge Limit ................ 8
  Developer build ........................ no
  Sanitizer .............................. no
  QtWebEngine required system libraries:
    fontconfig ........................... yes
    dbus ................................. yes
    nss .................................. yes
    khr .................................. yes
    glibc ................................ yes
  QtWebEngine required system libraries for qpa-xcb:
    x11 .................................. yes
    libdrm ............................... yes
    xcomposite ........................... yes
    xcursor .............................. yes
    xi ................................... yes
    xproto (glproto) ..................... yes
    xtst ................................. yes
    xkbfile .............................. yes
  Optional system libraries used:
    re2 .................................. no
    icu .................................. no
    libwebp, libwebpmux and libwebpdemux . yes
    opus ................................. yes
    ffmpeg ............................... yes
    libvpx ............................... no
    snappy ............................... no
    glib ................................. yes
    zlib ................................. yes
    minizip .............................. no
    libevent ............................. no
    libxml2 and libxslt .................. no
    lcms2 ................................ no
    png .................................. yes
    JPEG ................................. no
    harfbuzz ............................. no
    freetype ............................. yes
Qt WebEngineCore:
  Embedded build ......................... yes
  Full debug information ................. no
  Pepper Plugins ......................... no
  Printing and PDF ....................... no
  Proprietary Codecs ..................... yes
  Spellchecker ........................... yes
  Native Spellchecker .................... no
  WebRTC ................................. yes
  PipeWire over GIO ...................... no
  Geolocation ............................ yes
  WebChannel support ..................... yes
  Kerberos Authentication ................ no
  Extensions ............................. no
  Support qpa-xcb ........................ yes
  Building v8 snapshot supported ......... yes
  Use ALSA ............................... yes
  Use PulseAudio ......................... yes
Qt WebEngineQml:
  Support Qt WebEngine Qml ............... yes
  UI Delegates ........................... yes
  Test Support ........................... no
Qt WebEngineWidgets:
  Support Qt WebEngine Widgets ........... yes
Qt PDF:
  Support V8 ............................. no
  Support XFA ............................ no
  Support XFA-BMP ........................ no
  Support XFA-GIF ........................ no
  Support XFA-PNG ........................ no
  Support XFA-TIFF ....................... no
  Bitcode support ........................ no
  Use static runtime ..................... no
Qt PDF Widgets:
  Support Qt PDF Widgets ................. yes

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

Note: PKG_CONFIG_LIBDIR automatically set to /home/hesy/sysroot/usr/lib/pkgconfig:/home/hesy/sysroot/usr/share/pkgconfig:/home/hesy/sysroot/usr/lib/aarch64-linux-gnu/pkgconfig

Note: PKG_CONFIG_SYSROOT_DIR automatically set to /home/hesy/sysroot

Note: No wayland-egl support detected. Cross-toolkit compatibility disabled.

Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into '/home/hesy/sysroot/opt/aarch64'.

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

开始编译:

make -j4 && make install

发现一个坑的地方,如果加上recheck-all选项,在每次编译出错的时候,修改了错误或者增加了新的包后,make的时候就会从头开始编译,这太费时间了. 所以下面的配置去掉了--recheck-all

../configure -prefix /opt/aarch64 -make libs -xplatform linux-aarch64-gnu-g++ -sysroot /home/hesy/sysroot -webengine-webrtc  -webengine-pulseaudio -no-eglfs -webengine-opus -webengine-ffmpeg -webengine-proprietary-codecs -opensource -confirm-license

make -j8

15.25开始编译,半个小时能到qtwebengine的样子.

上面是能够编译成功的xcb 的配置,但是要使用gpu还是得编译上eglfs,要使eglfs mail 变成yes

编译命令如下

../configure -prefix /opt/aarch64 -make libs -xplatform linux-aarch64-gnu-g++ -sysroot /home/hesy/sysroot -webengine-webrtc  -webengine-pulseaudio  -webengine-opus -webengine-ffmpeg -webengine-proprietary-codecs -opensource -confirm-license

提示了一个fbdev_windows.h没有的错误,手动建立一下.

cat ~/sysroot/usr/include/EGL/fbdev_window.h 
/*
 1. This confidential and proprietary software may be used only as
 2. authorised by a licensing agreement from ARM Limited
 3. (C) COPYRIGHT 2008-2011 ARM Limited
 4. ALL RIGHTS RESERVED
 5. The entire notice above must be reproduced on all authorised
 6. copies and copies may only be made to the extent permitted
 7. by a licensing agreement from ARM Limited.
 */
 
/**
 8. @file fbdev_window.h
 9. @brief A window type for the framebuffer device (used by egl and tests)
 */
 
#ifndef _FBDEV_WINDOW_H_
#define _FBDEV_WINDOW_H_
 
#ifdef __cplusplus
extern "C" {
#endif
 
typedef enum
{
    FBDEV_PIXMAP_DEFAULT = 0,
    FBDEV_PIXMAP_SUPPORTS_UMP = (1<<0),
    FBDEV_PIXMAP_ALPHA_FORMAT_PRE = (1<<1),
    FBDEV_PIXMAP_COLORSPACE_sRGB = (1<<2),
    FBDEV_PIXMAP_EGL_MEMORY = (1<<3)        /* EGL allocates/frees this memory */
} fbdev_pixmap_flags;
 
typedef struct fbdev_window
{
    unsigned short width;
    unsigned short height;
} fbdev_window;
 
typedef struct fbdev_pixmap
{
    unsigned int height;
    unsigned int width;
    unsigned int bytes_per_pixel;
    unsigned char buffer_size;
    unsigned char red_size;
    unsigned char green_size;
    unsigned char blue_size;
    unsigned char alpha_size;
    unsigned char luminance_size;
    fbdev_pixmap_flags flags;
    unsigned short *data;
    unsigned int format; /* extra format information in case rgbal is not enough, especially for YUV formats */
} fbdev_pixmap;
 
#ifdef __cplusplus
}
#endif
#endif

重新configure ,然后就可以了.配置好后的输出

QPA backends:
  DirectFB ............................... no
  EGLFS .................................. yes
  EGLFS details:
    EGLFS OpenWFD ........................ no
    EGLFS i.Mx6 .......................... yes
    EGLFS i.Mx6 Wayland .................. yes
    EGLFS RCAR ........................... no
    EGLFS EGLDevice ...................... yes
    EGLFS GBM ............................ yes
    EGLFS VSP2 ........................... no
    EGLFS Mali ........................... yes
    EGLFS Raspberry Pi ................... no
    EGLFS X11 ............................ yes
  LinuxFB ................................ yes
  VNC .................................... yes
  XCB:
    Using system-provided xcb-xinput ..... yes
    Native painting (experimental) ....... no
    GL integrations:
      GLX Plugin ......................... yes
        XCB GLX .......................... yes
      EGL-X11 Plugin ..................... yes

开始编译,因为有8个cpu,咱们保守点,就用7个吧.

make -j7

大约半个小时能到qtwebengine,这个时候为了防止死机,一是加上交换内存,一个disable cpu数量.

增加swap空间
1.查看当前系统swap空间

free -m

2.增加swap文件

dd if=/dev/zero of=/swap/swapfile bs=1M count=8096

3.查看创建文件大小

du -sh /swap/swapfile

4.将目标文件标识为swap分区文件

mkswap /swap/swapfile

5.激活swap文件

swapon /swap/swapfile

6.修改/etc/fstab文件,在末行增加以下内容

vim /etc/fstab
/swap/swapfile swap swap defaults 0 0

7.查看是否挂载成功

出现错误:
cc1: error: one or more PCH files were found, but they were invalid
重新configure ,重新make

../configure -prefix "/home/odroid/qt/build" -release -confirm-license -opensource -xplatform linux-aarch64-gnu-g++ -opengl es2 -no-pch -no-xcb -skip wayland -skip webengine -sysroot /home/hesy/sysroot

.obj/qeglfsvivintegration.o:(.data.rel.ro._ZTV20QEglFSVivIntegration[_ZTV20QEglFSVivIntegration]+0x38): undefined reference to `QEglFSDeviceIntegration::createDisplay(_XDisplay*)'

~/build/qtlocation/src/3rdparty/clip2tri
~/build/qtlocation/src/3rdparty/clipper
~/build/qtlocation/src/3rdparty/poly2tri

重新make

cannot find -lqmapboxgl

不用管,重新编译就好了.
export QT_QPA_PLATFORM=eglfs
export QT_LOGGING_RULES=qt.qpa.*=true
export QT_QPA_EGLFS_DEBUG=1
export QT_QPA_EGLFS_INTEGRATION=eglfs_mali
export QT_DEBUG_PLUGINS=1

qt.qpa.egldeviceintegration: Using EGL device integration "eglfs_mali"
Unable to set double buffer mode! (无效的参数)

ls -lh libmali*
lrwxrwxrwx 1 root root 12 Nov 15 10:24 libmali-bifrost-g52-g2p0-wayland.so -> libmali.so.1
lrwxrwxrwx 1 root root 12 Nov 15 10:24 libmali.so -> libmali.so.1
lrwxrwxrwx 1 root root 16 Nov 15 10:24 libmali.so.1 -> libmali.so.1.9.0
-rwxr-xr-x 1 root root 44M Nov 16 01:26 libmali.so.1.9.0

cat /sys/devices/platform/fde60000.gpu/devfreq/fde60000.gpu/load

0表示gpu没有用起来

查看rk3568的gpu型号 rk356x libmali

cat /sys/devices/platform/*gpu/gpuinfo

Mali-G52 1 cores r1p0 0x7402

Qt可以通过窗口系统显示(x11,wayland),也可以直接显示通过一些插件,如QT EGLFS。
EGLFS是一个平台插件,可以在EGL和OpenGL ES之上运行Qt应用程序,而不需要通过X11或Wayland这样的实际窗口系统。

rk356x eglfs gbm x11 wayland

运行Qt程序,通过QPA(Qt Platform Abstraction)平台抽象显示,不同平台显示可以使用不同QPA插件, 一般Qt将根据平台选择一个默认的QPA插件(可以交叉编译库时configure配置), 也可以设置QT_QPA_PLATFORM环境变量或者-PLATFORM命令行参数选择不同的平台插件。

一般使用平台插件后端有:eglfs(需要OpenGL/EGL图形栈)、linuxfb(帧缓冲区接口)、 wayland和xcb(x11)。

linuxfb插件通过Linux的fbdev子系统直接写入帧缓冲区,不支持硬件渲染,显示性能可能会不好。 eglfs是qt自己实现的一个gui显示插件,eglfs使用opengles/egl进行gpu渲染后,直接送给drm去显示(使用opengles、egl接口,安装gbm或者x11-gbm版的libmali)

libEGL warning: DRI2: failed to authenticate

sudo apt-get install libegl libgles

X connection to :0 broken (explicit kill or server shutdown).

QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/aarch64-linux-gnu/qt5/plugins/platforms/egldeviceintegrations"

eglfs-mali
Unable to set double buffer mode
chown root /root
chown root /root/.ssh

快速验证测试,不编译webengine

../configure -prefix /opt/aarch64 -make libs -xplatform linux-aarch64-gnu-g++ -sysroot /home/hesy/sysroot1 -skip webengine -eglfs -recheck-all -opensource -confirm-license -opengl es2

apt install libgbm-dev libwayland*

9.06开始编译

在提示gbm version.h文件在global path找不到的时候,直接在编译机上安装libgbm-dev居然能解决.

使用ubuntu 20.04编译qt5.15.10

../configure -prefix /opt/aarch64 -make libs -xplatform linux-aarch64-gnu-g++ -sysroot /home/hesy/sysroot -kms -eglfs -opensource -confirm-license -opengl es2 -I/home/hesy/sysroot/usr/include -v -webengine-webrtc -webengine-pulseaudio -qt-ffmpeg -qt-opus -qt-webp

../configure -prefix /opt/aarch64 -make libs -xplatform linux-aarch64-gnu-g++ -sysroot /home/hesy/sysroot -kms -eglfs -opensource -confirm-license -opengl es2 -I/home/hesy/sysroot/usr/include -v -webengine-webrtc -webengine-pulseaudio -webengine-alsa -webengine-ffmpeg -webengine-opus -webengine-webp -webengine-proprietary-codecs

libvpx如果没打开,提示VPX_IMG_FMT_NV12未定义的错误的话
在/usr/include/vpx/vpx_image.h中添加
VPX_IMG_FMT_NV12 = VPX_IMG_FMT_PLANAR | 9,

configure后的完整输出如下

Configure summary:

Building on: linux-g++ (x86_64, CPU features: mmx sse sse2)
Building for: linux-aarch64-gnu-g++ (arm64, CPU features: cx16 neon)
Target compiler: gcc 9.4.0
Configuration: cross_compile compile_examples enable_new_dtags largefile neon precompile_header shared shared rpath release c++11 c++14 c++17 c++1z concurrent dbus reduce_exports stl
Build options:
  Mode ................................... release
  Optimize release build for size ........ no
  Building shared libraries .............. yes
  Using C standard ....................... C11
  Using C++ standard ..................... C++17
  Using ccache ........................... no
  Using new DTAGS ........................ yes
  Relocatable ............................ yes
  Using precompiled headers .............. yes
  Using LTCG ............................. no
  Target compiler supports:
    NEON ................................. 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
  Zstandard support ...................... no
Qt Core:
  DoubleConversion ....................... yes
    Using system DoubleConversion ........ yes
  GLib ................................... yes
  iconv .................................. no
  ICU .................................... yes
  Built-in copy of the MIME database ..... yes
  Tracing backend ........................ <none>
  Logging backends:
    journald ............................. no
    syslog ............................... no
    slog2 ................................ no
  PCRE2 .................................. yes
    Using system PCRE2 ................... yes
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
  OCSP-stapling .......................... yes
  SCTP ................................... no
  Use system proxies ..................... yes
  GSSAPI ................................. no
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 ............... yes
    PNG .................................. yes
      Using system libpng ................ yes
  Text formats:
    HtmlParser ........................... yes
    CssParser ............................ yes
    OdfWriter ............................ yes
    MarkdownReader ....................... yes
      Using system libmd4c ............... no
    MarkdownWriter ....................... yes
  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 ................................. yes
  Session Management ..................... yes
Features used by QPA backends:
  evdev .................................. yes
  libinput ............................... yes
  INTEGRITY HID .......................... no
  mtdev .................................. yes
  tslib .................................. no
  xkbcommon .............................. yes
  X11 specific:
    XLib ................................. yes
    XCB Xlib ............................. yes
    EGL on X11 ........................... yes
    xkbcommon-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 ............................ yes
    EGLFS VSP2 ........................... no
    EGLFS Mali ........................... yes
    EGLFS Raspberry Pi ................... no
    EGLFS X11 ............................ yes
  LinuxFB ................................ yes
  VNC .................................... yes
  XCB:
    Using system-provided xcb-xinput ..... yes
    Native painting (experimental) ....... no
    GL integrations:
      GLX Plugin ......................... no
      EGL-X11 Plugin ..................... yes
Qt Sql:
  SQL item models ........................ yes
Qt Widgets:
  GTK+ ................................... yes
  Styles ................................. Fusion Windows
Qt PrintSupport:
  CUPS ................................... yes
Qt Sql Drivers:
  DB2 (IBM) .............................. no
  InterBase .............................. no
  MySql .................................. no
  OCI (Oracle) ........................... no
  ODBC ................................... yes
  PostgreSQL ............................. yes
  SQLite2 ................................ no
  SQLite ................................. yes
    Using system provided SQLite ......... no
  TDS (Sybase) ........................... yes
Qt Testlib:
  Tester for item models ................. yes
Serial Port:
  ntddmodm ............................... no
Qt SerialBus:
  Socket CAN ............................. yes
  Socket CAN FD .......................... yes
  SerialPort Support ..................... yes
Further Image Formats:
  JasPer ................................. no
  MNG .................................... no
  TIFF ................................... yes
    Using system libtiff ................. yes
  WEBP ................................... yes
    Using system libwebp ................. yes
Qt QML:
  QML network support .................... yes
  QML debugging and profiling support .... yes
  QML just-in-time compiler .............. yes
  QML sequence object .................... yes
  QML XML http request ................... yes
  QML Locale ............................. yes
Qt QML Models:
  QML list model ......................... 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
QtQuick3D:
  Assimp ................................. yes
  System Assimp .......................... no
Qt Scxml:
  ECMAScript data model for QtScxml ...... yes
Qt Gamepad:
  SDL2 ................................... no
Qt 3D:
  Assimp ................................. yes
  System Assimp .......................... no
  Output Qt3D GL traces .................. no
  Use SSE2 instructions .................. no
  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
  RHI Renderer ........................... no
Qt 3D GeometryLoaders:
  Autodesk FBX ........................... no
Qt Wayland Client ........................ no
Qt Wayland Compositor .................... no
Qt Bluetooth:
  BlueZ .................................. yes
  BlueZ Low Energy ....................... yes
  Linux Crypto API ....................... yes
  Native Win32 Bluetooth ................. no
  WinRT Bluetooth API (desktop & UWP) .... no
  WinRT advanced bluetooth low energy 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 .......................... yes
  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 TextToSpeech:
  Flite .................................. no
  Flite with ALSA ........................ no
  Speech Dispatcher ...................... no
Qt Tools:
  Qt Assistant ........................... yes
  Qt Designer ............................ yes
  Qt Distance Field Generator ............ yes
  kmap2qmap .............................. yes
  Qt Linguist ............................ yes
  Mac Deployment Tool .................... no
  makeqpf ................................ yes
  pixeltool .............................. yes
  qdbus .................................. yes
  qev .................................... yes
  Qt Attributions Scanner ................ yes
  qtdiag ................................. yes
  qtpaths ................................ yes
  qtplugininfo ........................... yes
  Windows deployment tool ................ no
  WinRT Runner Tool ...................... no
Qt Tools:
  QDoc ................................... no
Qt WebEngine Build Tools:
  Use System Ninja ....................... no
  Jumbo Build Merge Limit ................ 8
  Developer build ........................ no
  Sanitizer .............................. no
  QtWebEngine required system libraries:
    fontconfig ........................... yes
    dbus ................................. yes
    nss .................................. yes
    khr .................................. yes
    glibc ................................ yes
  QtWebEngine required system libraries for qpa-xcb:
    x11 .................................. yes
    libdrm ............................... yes
    xcomposite ........................... yes
    xcursor .............................. yes
    xi ................................... yes
    xproto (glproto) ..................... yes
    xtst ................................. yes
    xkbfile .............................. yes
  Optional system libraries used:
    re2 .................................. no
    icu .................................. no
    libwebp, libwebpmux and libwebpdemux . yes
    opus ................................. yes
    ffmpeg ............................... yes
    libvpx ............................... yes
    snappy ............................... yes
    glib ................................. yes
    zlib ................................. yes
    minizip .............................. no
    libevent ............................. yes
    libxml2 and libxslt .................. yes
    lcms2 ................................ yes
    png .................................. yes
    JPEG ................................. yes
    harfbuzz ............................. no
    freetype ............................. yes
Qt WebEngineCore:
  Embedded build ......................... yes
  Full debug information ................. no
  Pepper Plugins ......................... no
  Printing and PDF ....................... no
  Proprietary Codecs ..................... yes
  Spellchecker ........................... yes
  Native Spellchecker .................... no
  WebRTC ................................. yes
  PipeWire over GIO ...................... no
  Geolocation ............................ yes
  WebChannel support ..................... yes
  Kerberos Authentication ................ no
  Extensions ............................. no
  Support qpa-xcb ........................ yes
  Building v8 snapshot supported ......... yes
  Use ALSA ............................... yes
  Use PulseAudio ......................... yes
Qt WebEngineQml:
  Support Qt WebEngine Qml ............... yes
  UI Delegates ........................... yes
  Test Support ........................... no
Qt WebEngineWidgets:
  Support Qt WebEngine Widgets ........... yes
Qt PDF:
  Support V8 ............................. no
  Support XFA ............................ no
  Support XFA-BMP ........................ no
  Support XFA-GIF ........................ no
  Support XFA-PNG ........................ no
  Support XFA-TIFF ....................... no
  Bitcode support ........................ no
  Use static runtime ..................... no
Qt PDF Widgets:
  Support Qt PDF Widgets ................. yes

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

Note: PKG_CONFIG_LIBDIR automatically set to /home/hesy/sysroot/usr/lib/pkgconfig:/home/hesy/sysroot/usr/share/pkgconfig:/home/hesy/sysroot/usr/lib/aarch64-linux-gnu/pkgconfig

Note: PKG_CONFIG_SYSROOT_DIR automatically set to /home/hesy/sysroot

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.

Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into '/home/hesy/sysroot/opt/aarch64'.

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

make

添加 Qt 的软件源

sudo add-apt-repository ppa:beineri/opt-qt-5.15.0-focal

此命令会向 Ubuntu 的 package manager 中添加 Qt 的软件源。

更新软件包列表

sudo apt-get update

安装 Qt

sudo apt-get install qt515base qt515charts-no-lgpl qt515connectivity qt515graphicaleffects qt515imageformats qt515quickcontrols qt515quickcontrols2 qt515svg qt515tools qt515translations qt515wayland qt515websockets qt515webview

也可以这样:

sudo apt-get install qt5*

以上命令会安装 Qt 5.15 版本和相关组件。

请注意,以上示例中的命令是用于安装 Qt 5.15 的,你可以根据自己的需求,替换软件源中的版本号进行安装。

最后,你可以通过以下命令验证是否安装成功:

qmake -v

该命令会显示已安装的 Qt 版本信息。
Referenced from:https://juejin.cn/s/ubuntu%25E5%25AE%2589%25E8%25A3%2585qt%25E5%2591%25BD%25E4%25BB%25A4

Qt Version Chromium Version
6.5.0 108.0.5359.181
6.4.0 102.0.5005.177
6.3.0 94.0.4606.126
6.2.6-6.2.8 102.0.5005.177
6.2.4-6.2.5 94.0.4606.126
6.2.0 90.0.4430.228
5.15.3–5.15.x 87.0.4280.144
5.15.2 83.0.4103.122
5.15.0–5.15.1 80.0.3987.136
5.14.0–5.14.1 77.0.3865.98
5.13.0–5.13.2 73.0.3683.105
5.12.0–5.12.7 69.0.3497.113
5.11.0–5.11.3 65.0.3325.151
5.10.1 61.0.3163.140
5.10.0 61.0.3163.99
5.9.0–5.9.9 56.0.2924.122
5.8.0 53.0.2785.148
5.7.0–5.7.1 49.0.2623.111
5.6.3 49.0.2623.111
5.6.0–5.6.2 45.0.2554.101
5.5.0–5.5.1 40.0.2214.115
5.4.0–5.4.2 37.0.2062.103

https://wiki.qt.io/QtWebEngine/ChromiumVersions