You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

编译带专有编解码器的Qt6 QtWebEngine(Windows平台)

Windows平台编译带专有编解码器的Qt6(含QtWebEngine)

作为业余开发者,若需让QWebEngineView加载网页时正常播放音视频,需从源码编译集成专有编解码器的Qt6。以下是Windows平台可重复的分步编译流程:

系统准备

注意:以下工具版本至关重要,务必严格匹配

  • 安装Visual Studio 2026(18.0.2):打开Visual Studio安装器,点击“修改”切换到“单个组件”标签,勾选以下组件:
    • Windows 11 SDK 10.0.22621.0
    • C++ ATL for x64/x86(Latest MSVC)
    • MSVC v143 - VS 2022 C++ x64/x86 build tools(v14.44-17.14)
  • 安装Python v3.11或版本≥v3.10
  • 安装CMake v3.21.7:安装时选择“Add CMake to the system path for all users”
  • 安装node.js 24.11.1或最新版本
  • 安装Bison(最新版本)
  • 安装Flex(最新版本)
  • 安装gperf(最新版本)
  • 下载独立版ninja.exe,将其放入GnuWin32的bin目录(默认路径为C:\Program Files(x86)\GnuWin32\bin)

关闭Windows实时保护:
Windows设置 → 病毒和威胁防护 → 病毒和威胁防护设置 → 管理设置 → 关闭实时保护

编译Qt6与QtWebEngine

  1. 打开命令提示符,调用Visual Studio命令提示符:
    "C:\Program Files\Microsoft Visual Studio\18\Community\Common7\Tools\VsDevCmd.bat" -arch=amd64 -host_arch=amd64 -vcvars_ver=14.44
    
  2. 设置编译环境变量:
    set "PATH=C:\Program Files (x86)\GnuWin32\bin;%PATH%"
    set CC="C:/Program Files/Microsoft Visual Studio/18/Community/VC/Tools/MSVC/14.44.35207/bin/HostX64/x64/cl.exe"
    set CXX="C:/Program Files/Microsoft Visual Studio/18/Community/VC/Tools/MSVC/14.44.35207/bin/HostX64/x64/cl.exe"
    
  3. 安装Python依赖库:
    pip install html5lib
    
  4. 下载Qt 6.8源码:
    cd \
    git clone git://code.qt.io/qt/qt5.git qt6
    cd qt6
    git checkout origin/6.8
    .\init-repository --module-subset=qtbase,qtshadertools,qtdeclarative,qtwebengine --no-resolve-deps
    
  5. 创建编译目录:
    mkdir build
    cd build
    
  6. 配置不含QtWebEngine的Qt6:
    ..\configure.bat -release -nomake tests -nomake examples -no-pch -skip qtwebengine -prefix C:\opt\qt\6.8
    
  7. 编译并安装Qt6(此过程耗时较长):
    cmake --build . --parallel
    cmake --install .
    
    编译完成后,Qt6文件将被安装到C:\opt\qt\6.8目录下
  8. 在编译目录中创建QtWebEngine子目录:
    mkdir qtwebengine
    cd qtwebengine
    
  9. 配置带专有编解码器的QtWebEngine:
    \opt\qt\6.8\bin\qt-configure-module ..\..\qtwebengine -webengine-proprietary-codecs
    
  10. 代码修改(解决MSVC v14.44兼容问题):
    • 打开C:\qt6\qtwebengine\src\3rdparty\chromium\v8\src\heap\cppgc\marking-state.h,定位到第345行,将:
      return MutatorMarkingState::BasicMarkingState::MarkNoPush(header);
      
      修改为:
      return MarkNoPush(header);
      
    • 打开C:\qt6\qtwebengine\src\3rdparty\chromium\components\autofill\core\browser\form_processing\label_processing_util.h,在#include "base/strings/string_piece.h"之后添加:
      #include <string_view>
      #include <string>
      
  11. 编译并安装QtWebEngine(此过程耗时较长):
    cmake --build . --parallel
    cmake --install .
    

内容的提问来源于stack exchange,提问作者Jeremy Wilson

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.11 23:43:14