windows10编译与调试webrtc


代理设置

以下流程使用国内网络一般是行不通的,需要设置代理才有可能成功

Lin@DESKTOP-05I624T MINGW64 /e/webrtc
$ export http_proxy=http://127.0.0.1:7890

Lin@DESKTOP-05I624T MINGW64 /e/webrtc
$ export https_proxy=http://127.0.0.1:7890

一、depot_tools下载

  1. 进入depot_tools网页,使用git clone下载depot_tools
  2. 将depot_tools目录添加到PATH环境变量中
  3. 添加环境变量DEPOT_TOOLS_WIN_TOOLCHAIN=0
  4. gclient更新depot_tools

二、webrtc下载

众所周知,由于墙的存在,在国内是无法下载到webrtc完整源码的,只能借助一些特殊的手段。本人试过两种方法,这里简单介绍一下。

1、租海外服务器下载

方法就是租一台海外服务器,将源码下载好后上传至云盘,然后再使用国内的网络下载下来,这种方法比较麻烦,不太推荐。具体方法可参考如下链接。

webrtc windows for vs 2019 编译工程下载

2、挂代理下载

方法二就是使用代理进行下载,这种方法比较方便快捷

  1. mkdir webrtc-checkout
  2. cd webrtc-checkout
  3. fetch --nohooks webrtc
  4. gclient sync

使用该方法遇到了如下问题

NOTICE: You have PROXY values set in your environment, but gsutil in depot_tools does not (yet) obey them.
Also, --no_auth prevents the normal BOTO_CONFIG environment variable from being used.
To use a proxy in this situation, please supply those settings in a .boto file pointed to by the NO_AUTH_BOTO_CONFIG environment var.

解决办法是创建一个叫xxx.boto的文件,文件内容如下

[Boto]
proxy = 127.0.0.1
proxy_port = 7890
proxy_type = http

然后添加环境变量NO_AUTH_BOTO_CONFIG
在这里插入图片描述


三、vs工程文件生成与编译

webrtc下载完成后没有切版本,应该就是当前最新的版本

1、生成Visual Studio工程

在cmd中 cd进src目录分别执行以下目录
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
//--vs2022安装目录
set GYP_MSVS_VERSION=2022
set GYP_MSVS_OVERRIDE_PATH=F:\Program Files\Microsoft Visual Studio\2022\Community        
set GYP_GENERATORS=msvs-ninja,ninja
//--Win10SDK目录
set WINDOWSSDKDIR=D:\Windows Kits\10        

//--生成vs2022工程,在out/Default目录下
gn gen --ide=vs2022 out/Default

1.1、生成vs工程中遇到的问题

Traceback (most recent call last):
  File "E:/webrtc/webrtc-chechout/src/build/vs_toolchain.py", line 589, in <module>
    sys.exit(main())
  File "E:/webrtc/webrtc-chechout/src/build/vs_toolchain.py", line 585, in main
    return commands[sys.argv[1]](*sys.argv[2:])
  File "E:/webrtc/webrtc-chechout/src/build/vs_toolchain.py", line 571, in GetToolchainDir
    ToGNString(win_sdk_dir), ToGNString(GetVisualStudioVersion()),
  File "E:/webrtc/webrtc-chechout/src/build/vs_toolchain.py", line 202, in GetVisualStudioVersion
    raise Exception('No supported Visual Studio can be found.'
Exception: No supported Visual Studio can be found. Supported versions are: 17.0 (2022), 16.0 (2019), 15.0 (2017).
ERROR at //build/config/win/visual_studio_version.gni:29:7: Script returned non-zero exit code.
      exec_script("../../vs_toolchain.py", [ "get_toolchain_dir" ], "scope")
      ^----------
Current dir: E:/webrtc/webrtc-chechout/src/out/Default/
Command: E:/webrtc/depot_tools/bootstrap-2@3_8_10_chromium_26_bin/python3/bin/python3.exe E:/webrtc/webrtc-chechout/src/build/vs_toolchain.py get_toolchain_dir
Returned 1.
See //build/toolchain/win/BUILD.gn:5:1: whence it was imported.
import("//build/config/win/visual_studio_version.gni")
^----------------------------------------------------
See //BUILD.gn:39:3: which caused the file to be included.
  group("default") {
  ^------------------

解决办法是修改vs_toolchain.py脚本(src/build/路径下),将vs路径写死

在这里插入图片描述

接下来又出现了另一个错误

Traceback (most recent call last):
  File "E:/webrtc/webrtc-chechout/src/build/toolchain/win/setup_toolchain.py", line 328, in <module>
    main()
  File "E:/webrtc/webrtc-chechout/src/build/toolchain/win/setup_toolchain.py", line 274, in main
    env = _LoadToolchainEnv(cpu, toolchain_root, win_sdk_path, target_store)
  File "E:/webrtc/webrtc-chechout/src/build/toolchain/win/setup_toolchain.py", line 190, in _LoadToolchainEnv
    return _ExtractImportantEnvironment(variables)
  File "E:/webrtc/webrtc-chechout/src/build/toolchain/win/setup_toolchain.py", line 68, in _ExtractImportantEnvironment
    raise Exception(
Exception: Path "C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um" from environment variable "include" does not exist. Make sure the necessary SDK is installed.
ERROR at //build/toolchain/win/win_toolchain_data.gni:9:7: Script returned non-zero exit code.
      exec_script("//build/toolchain/win/setup_toolchain.py",
      ^----------
Current dir: E:/webrtc/webrtc-chechout/src/out/Default/
Command: E:/webrtc/depot_tools/bootstrap-2@3_8_10_chromium_26_bin/python3/bin/python3.exe E:/webrtc/webrtc-chechout/src/build/toolchain/win/setup_toolchain.py "F:\Program Files\Microsoft Visual Studio\2022\Community" "C:\Program Files (x86)\Windows Kits\10" "C:\WINDOWS\System32;C:\WINDOWS\SysWOW64;Arm64Unused" win x86 environment.x86
Returned 1.
See //build/toolchain/win/toolchain.gni:14:1: whence it was imported.
import("//build/toolchain/win/win_toolchain_data.gni")
^----------------------------------------------------
See //build/toolchain/win/BUILD.gn:6:1: whence it was imported.
import("//build/toolchain/win/toolchain.gni")
^-------------------------------------------
See //BUILD.gn:39:3: which caused the file to be included.
  group("default") {
  ^------------------

上面的意思大致是说需要10.0.22621.0版本的SDK,而我当时的版本是10.0.20348.0,解决方法就是在Visual Studio Installer中安装10.0.22621.0版本的SDK

在这里插入图片描述
虽然上面写的是 Windows 11 SDK(10.0.22621.0) 但Win10系统也能用。另外顺便检查一下实时调试器有没有安装,没有的话也顺便安装一下。


工程生成成功

E:\webrtc\webrtc-chechout\src>gn gen --ide=vs2022 out/Default
Generating Visual Studio projects took 1914ms
Done. Made 1782 targets from 295 files in 6194ms

打开out/Default目录就能看见vs工程文件了!
在这里插入图片描述

2、webrtc编译

E:\webrtc\webrtc-chechout\src>ninja -C out/Default
ninja: Entering directory `out/Default'
[6313/6313] STAMP obj/default.stamp

在此之后,就可在Visual Studio中对webrtc进行调试了
在这里插入图片描述

如果想清理工程

gn clean out/Default

四、demo运行问题

【Bug修复记录】WebRTC源码demo无法运行
Issue 13498 attachment: fix.patch

在这里插入图片描述


五、参考链接

webrtc windows for vs 2019 编译工程下载
WEBRTC–windows下载及编译
Windows平台WebRTC编译-VS2017
Webrtc中如何确定通常意义上说的M108,M90是指什么

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Windows 10上编译WebRTC可以按照以下步骤进行: 1. 首先,确保你的系统已经安装了Visual Studio。WebRTCWindows上的编译需要使用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项目的文档和最新的指南进行操作。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值