WebRTC Win10平台编译下载错误


配置如下:

  • GYP_MSVS_VERSION设置VisualStudio的版本为2017
  • DEPOT_TOOLS_WIN_TOOLCHAIN设置不依赖Depot内置内置的工具链(Tool Chain)
  • 较新版本的WebRTC使用Python3.8,老版本的使用Python2.7,需要在此之前配置好
export GYP_MSVS_VERSION=2017
export DEPOT_TOOLS_WIN_TOOLCHAIN=0

gn gen out/win --args='
target_os = "win"
target_cpu = "x86"
is_debug = false
rtc_enable_protobuf = false
rtc_libvpx_build_vp9 = false
rtc_use_h264 = true
rtc_use_openmax_dl = false
rtc_enable_sctp = false
rtc_include_tests = false
use_cxx11 = false
' --ide=vs2017

fetch错误

使用fetch下载Windows平台WebRTC代码的时候遇到了如下错误

The system cannot find the file C:\Users\stoneliu\Desktop\depot_tools\python3_bin_reldir.txt.
[E2021-12-30T11:28:59.735399+08:00 11572 0 annotate.go:273] goroutine 1:
#0 go.chromium.org/luci/vpython/venv/config.go:309 - venv.(*Config).resolvePythonInterpreter()
  reason: none of [C:\Users\stoneliu\Desktop\depot_tools\\\python3.exe] matched specification 3.8.0

#1 go.chromium.org/luci/vpython/venv/config.go:153 - venv.(*Config).resolveRuntime()
  reason: failed to resolve system Python interpreter

#2 go.chromium.org/luci/vpython/venv/venv.go:143 - venv.With()
  reason: failed to resolve python runtime

#3 go.chromium.org/luci/vpython/run.go:60 - vpython.Run()
#4 go.chromium.org/luci/vpython/application/application.go:327 - application.(*application).mainImpl()
#5 go.chromium.org/luci/vpython/application/application.go:416 - application.(*Config).Main.func1()
#6 go.chromium.org/luci/vpython/application/support.go:46 - application.run()
#7 go.chromium.org/luci/vpython/application/application.go:415 - application.(*Config).Main()
#8 vpython/main.go:112 - main.mainImpl()
#9 vpython/main.go:118 - main.main()
#10 runtime/proc.go:225 - runtime.main()
#11 runtime/asm_amd64.s:1371 - runtime.goexit()

方案一(不推荐)

这个是因为我使用的是Win10系统,而且Python是从AppStore下载的,depot_tools没能识别到Python的路径导致的。方案一就是手动指定,不推荐这样的做法。

#!/usr/bin/env bash

function bootstrap_python3 {
  base_dir=$(dirname "${BASH_SOURCE[0]}")

  cd "${base_dir}"

  # if [ -e ".bleeding_edge" ]; then
  #   CIPD_MANIFEST="bootstrap/manifest_bleeding_edge.txt"
  # else
  #   CIPD_MANIFEST="bootstrap/manifest.txt"
  # fi

  # while IFS= read -r line; do
  #   if [[ $line =~ ^[^#].*cpython3/.*version:(.*)$ ]]; then
  #     PYTHON3_VERSION=${BASH_REMATCH[1]}
  #     PYTHON3_VERSION=${PYTHON3_VERSION//[[:space:]]/}
  #   fi
  # done < $CIPD_MANIFEST
  # if [ "X$PYTHON3_VERSION" == "X" ]; then
  #   echo Could not extract Python 3 version from manifest.
  #   return 1
  # fi

  # BOOTSTRAP_PATH="bootstrap-${PYTHON3_VERSION}_bin"
  
  # # Install CIPD packages. The CIPD client self-bootstraps.
  # "cipd" ensure -log-level warning -ensure-file "${CIPD_MANIFEST}" \
  #     -root "$BOOTSTRAP_PATH"

  # BOOTSTRAP_PYTHON_BIN="${BOOTSTRAP_PATH}/python3/bin/python3"
  BOOTSTRAP_PYTHON_BIN="C:\Users\stoneliu\AppData\Local\Microsoft\WindowsApps\python"
  "$BOOTSTRAP_PYTHON_BIN" "bootstrap/bootstrap.py" --bootstrap-name "$BOOTSTRAP_PATH"

  cd - > /dev/null
}

方案二

让depot_tools自动下载它需要的Python库。打开depot_tools/bootstrap文件夹,点击执行win_tools.bat脚本,它就会下载所需的Python到depot_tools适合的目录了

获取VS信息错误

使用gn gen去生成.ninja文件的时候遇到如下错误

ERROR at dynamically parsed input that //build/config/win/visual_studio_version.gni:27:7 loaded :7:3: This is not a valid number.
[0x7FFFE82EE044] ANOMALY: use of REX.w is meaningless (default operand size is 64)
 -^
See //build/config/win/BUILD.gn:11:1: whence it was imported.
import("//build/config/win/visual_studio_version.gni")
^----------------------------------------------------
See //build/config/BUILDCONFIG.gn:357:5: which caused the file to be included.
    "//build/config/win:unicode",
    ^---------------------------
[0x7FFFE82EE044] ANOMALY: use of REX.w is meaningless (default operand size is 64)
[0x7FFFE82EE044] ANOMALY: use of REX.w is meaningless (default operand size is 64)

于是查看对应的代码,发现是在获取vs信息(exec_script("../../vs_toolchain.py", [ "get_toolchain_dir" ], "scope"))的时候遇到了错误

if (visual_studio_path == "") {
  toolchain_data =
      exec_script("../../vs_toolchain.py", [ "get_toolchain_dir" ], "scope")
  visual_studio_path = toolchain_data.vs_path
  windows_sdk_path = toolchain_data.sdk_path
  visual_studio_version = toolchain_data.vs_version
  wdk_path = toolchain_data.wdk_dir
  visual_studio_runtime_dirs = toolchain_data.runtime_dirs
} else {
  assert(visual_studio_version != "",
         "You must set the visual_studio_version if you set the path")
  assert(wdk_path != "",
         "You must set the wdk_path if you set the visual studio path")
  visual_studio_runtime_dirs = []
}

于是在终端单独执行这个脚本python build/vs_toolchain.py get_toolchain_dir输出信息如下,说明是能正确的获取到当前vs信息的,但是多了一行信息[0x7FFFE82EE044] ANOMALY: use of REX.w is meaningless (default operand size is 64),是解析这个语句出错导致的。

vs_path = "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community"
sdk_path = "C:\\Program Files (x86)\\Windows Kits\\10"
vs_version = "2022"
wdk_dir = ""
runtime_dirs = "C:\\Windows\\System32;C:\\Windows\\SysWOW64;Arm64Unused"

[0x7FFFE82EE044] ANOMALY: use of REX.w is meaningless (default operand size is 64)

解决方案

升级Win10以后在终端下执行一些命名会多一条这样的[0x7FFFE82EE044] ANOMALY: use of REX.w is meaningless (default operand size is 64)信息在输出内容之后,exec_script在解析输出内容的时候报错了,解决方案就是不让它输出多余的信息。解决方案就是修改注册表。

  • 路径:\HKEY_LOCAL_MACHINE\SOFTWARE\TEC\Ocular.3\agent\config
  • 字段:hookapi_filterproc_external
  • 内容:如果该字段已经存在,在该字段的最后追加Python相关的可执行即可(;python.exe;python3.8.exe)
    在这里插入图片描述

Windows 10 SDK

因为是新的电脑,所以不存在Windows 10 SDK,于是报了如下错误

Traceback (most recent call last):
  File "C:/Users/stoneliu/Desktop/chromium/src/build/vs_toolchain.py", line 585, in <module>
    sys.exit(main())
  File "C:/Users/stoneliu/Desktop/chromium/src/build/vs_toolchain.py", line 581, in main
    return commands[sys.argv[1]](*sys.argv[2:])
  File "C:/Users/stoneliu/Desktop/chromium/src/build/vs_toolchain.py", line 412, in CopyDlls
    _CopyDebugger(target_dir, target_cpu)
  File "C:/Users/stoneliu/Desktop/chromium/src/build/vs_toolchain.py", line 445, in _CopyDebugger
    raise Exception('%s not found in "%s"\r\nYou must install'
Exception: dbghelp.dll not found in "C:\Program Files (x86)\Windows Kits\10\Debuggers\x86\dbghelp.dll"
You must installWindows 10 SDK version 10.0.19041.0 including the "Debugging Tools for Windows" feature.
ERROR at //build/toolchain/win/BUILD.gn:55:3: Script returned non-zero exit code.
  exec_script("../../vs_toolchain.py",
  ^----------
Current dir: C:/Users/stoneliu/Desktop/chromium/src/out/win/
Command: C:/Users/stoneliu/AppData/Local/Microsoft/WindowsApps/python3.exe C:/Users/stoneliu/Desktop/chromium/src/build/vs_toolchain.py copy_dlls C:/Users/stoneliu/Desktop/chromium/src/out/win Release x86
Returned 1 and printed out:

Copying C:\Windows\SysWOW64\msvcp140.dll to C:/Users/stoneliu/Desktop/chromium/src/out/win\msvcp140.dll...
Copying C:\Windows\SysWOW64\vccorlib140.dll to C:/Users/stoneliu/Desktop/chromium/src/out/win\vccorlib140.dll...
Copying C:\Windows\SysWOW64\vcruntime140.dll to C:/Users/stoneliu/Desktop/chromium/src/out/win\vcruntime140.dll...
Copying C:\Windows\SysWOW64\ucrtbase.dll to C:/Users/stoneliu/Desktop/chromium/src/out/win\ucrtbase.dll...

解决方案

下载安装Windows 10 SDK即可,下载链接

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在Windows 10上编译WebRTC可以按照以下步骤进行: 1. 首先,确保你的系统已经安装了Visual Studio。WebRTC在Windows上的编译需要使用Visual Studio环境。 2. 下载depot_tools,它是一个用于下载WebRTC源代码的工具。可以在GitHub上找到depot_tools的源码,并按照文档中的步骤进行安装。 3. 打开命令提示符或PowerShell,并导航到你想要保存WebRTC源代码的文件夹。 4. 使用以下命令克隆WebRTC的代码仓库: ``` git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git ``` 5. 添加depot_tools到系统的环境变量中。在命令提示符或PowerShell中,输入以下命令: ``` set PATH=%PATH%;[depot_tools目录的路径] ``` 这将使你能够在任何目录中使用depot_tools中的命令。 6. 使用以下命令下载WebRTC的源代码: ``` fetch --nohooks webrtc ``` 此命令将下载WebRTC的源代码到当前文件夹下的src目录中。 7. 进入src目录,并使用命令执行Hook脚本以获取编译所需的依赖项: ``` cd src gclient runhooks ``` 8. 接下来,根据你的编译需求选择合适的方案,并使用gn生成构建配置文件。 如果你想做一个默认构建,可以使用以下命令: ``` gn gen out/Default ``` 如果你想构建一个调试版本,可以使用以下命令: ``` gn gen out/Debug --args="is_debug=true" ``` 构建配置文件将生成在out/Default或out/Debug目录中。 9. 最后,使用ninja命令来编译WebRTC: ``` ninja -C out/Default ``` 或者,如果你选择了调试版本: ``` ninja -C out/Debug ``` 这将编译WebRTC并生成可执行文件和库文件。 以上是在Windows 10上编译WebRTC的简要步骤。请注意,这只是一个概述,实际操作可能会根据具体环境有所不同。在实际操作中,请根据WebRTC项目的文档和最新的指南进行操作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值