在 Windows 10 上构建 CEF

Posted

技术标签:

【中文标题】在 Windows 10 上构建 CEF【英文标题】:Build CEF on Windows 10 【发布时间】:2020-12-03 21:44:09 【问题描述】:

到目前为止,在 Windows 10 中编译 CEF 已经进行了一周的工作和各种修复。现在看来我已经到了编译的最后一步,但我还有一个问题尚未解决,Ninja 失败了

[30545/36949] 操作 //tools/v8_context_snapshot:gener..._context_snapshot(//build/toolchain/win:win_clang_x86) 失败:v8_context_snapshot.bin C:/code/depot_tools/bootstrap-3_8_0_chromium_8_bin/python/bin/python.exe ../../build/gn_run_binary.py ./v8_context_snapshot_generator --output_file=v8_context_snapshot.bin [1203/185351.657:FATAL:com_init_check_hook.cc(159)] 检查失败:假。 CoCreateInstance 似乎以前打过补丁。 尝试写入

我的环境 Windows10、VS 2017 v 15.9.28、Win 10.0.17763 SDK 和 Ninja。 有谁知道它可以是什么? 非常感谢您的问候

【问题讨论】:

【参考方案1】:

我终于能够为所选版本 v75 编译带有 .mp4 支持的 CEF。我与大家分享在 windows 环境下编译所需的所有步骤。 分支 3770 需要什么 --> Chromium 版本 v 75。 Win 7+,VS2017 15.7.1+,Win 10.0.17763 SDK,Ninja,至少 8GB 内存和 40GB 可用磁盘空间。需要特别注意SDK的版本,单独安装,不要和Visual Studio一起安装,而且一定要注明的那个,如果有以后的版本就完全卸载了。 通过将以下参数传递给 Visual Studio 安装程序来安装所需的 Visual Studio 子组件:

$ PATH_TO_INSTALLER.EXE ^
--add Microsoft.VisualStudio.Workload.NativeDesktop ^
--add Microsoft.VisualStudio.Component.VC.ATLMFC ^
--includeRecommended

见https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding.md#markdown-header-current-release-branches-supported。 下载并逐步正确构建请参阅:https://bitbucket.org/chromiumembedded/cef/wiki/MasterBuildQuickStart 这个程序因为它只是Master的下载过程, 如果要编译特定分支,请编译下载路径并相应修改 update.bat 文件。 设置所有必要的环境变量并重新启动PC:

变量 CEF_USE_GN 值 CEF_USE_GN=1 变量 GN_DEFINES 值设置 GN_DEFINES=proprietary_codecs=1 ffmpeg_branding=Chrome 变量路径将 C:\code\depot_tools 的值添​​加为文件夹 depot_tools 的路径。 变量 DEPOT_TOOLS_WIN_TOOLCHAIN 值 DEPOT_TOOLS_WIN_TOOLCHAIN=0。 例如对于 3770 分支 构建路径 C:\code\chromium_git3770

并在 update.bat 中写入如下:

设置 CEF_USE_GN=1 设置 GN_DEFINES=is_official_build=true 专有编解码器=true ffmpeg_branding=Chrome 设置 GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/* python ..\automate\automate-git.py --download-dir=C:\code\chromium_git3770 --depot-tools-dir=C:\code\depot_tools --branch=3770 --no-distrib --no -构建

和 Create.bat 类似: 设置 CEF_USE_GN=1 设置 GN_DEFINES=is_official_build=true 专有编解码器=true ffmpeg_branding=Chrome 设置 GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/* 调用 cef_create_projects.bat

解决错误:

使用 Ninja 构建时出错 尝试始终从 cmd 运行 chromium/src 目录中的“gclient runhooks” 此命令更新 depot_tools 中的文件 在 Windows 10 上,尤其是存在各种问题和各种问题(缺少 node.js 等)

ImportError: 没有名为 win32file 的模块 在 python 文件夹上安装正确的 WinApi。 C:\code\depot_tools>python -m pip install pywin32

错误失败:v8_context_snapshot.bin 建议在完全构建之前运行“gn clean”,在所有构建路径中,在每次构建错误之后。 等待大约 4 小时,您将完成构建。

【讨论】:

您好,感谢您的详细流程。在我的情况下,我能够使用bitbucket.org/chromiumembedded/cef/wiki/MasterBuildQuickStart 进行构建但是,当我尝试从 ninja 构建的应用程序中导入导出的 CefSharp 库时出现错误。这是我在应用程序中遇到的错误:“无法加载文件或程序集‘CefSharp.Core.Runtime.dll’”。此外,使用 ninja 构建时,我下载库时没有相同的文件。你能告诉我你如何导出图书馆吗?谢谢:)

以上是关于在 Windows 10 上构建 CEF的主要内容,如果未能解决你的问题,请参考以下文章

在 Mac M1 上构建 Dockerfile 成功,在 Windows 10 WSL 2 上失败

Windows 10 使用 Visual Studio Express 2015 构建程序 使用 SQL Server CE 只是挂在其他平台上

mysql源码在windows 10上通过vs2019构建方法

如何在 Windows 上构建 Mono 3.4.0/3.4.1

尝试在 Windows 10 x64 上使用 Visual Studio 2019 v16.6.5 从 github 构建 GDAL

如何在 Windows 10 上使用 Visual Studio 2015 x64 配置和构建 Tesseract OCR C++