Windows10下使用VS2019编译WebRTC

操作系统

  • Windows10专业版1909,64位版本
  • 内存12G,建议越大越好
  • 预留了50G磁盘空间,注意有大于4G文件,所以文件系统格式需要是NTFS

VS2019

  • 使用的是enterprise版,community版本也没有问题。
  • 在C盘安装,安装路径使用默认,据说修改会引起某些问题。
  • Desktop development with C++组件选择安装10.0.18362或以上的Win10 SDK,最新版的VS2019已经默认了。
  • 后面还需要修改Win10 SDK的安装,添加安装调试工具Debugging Tools for Windows。
  • Desktop development with C++组件选择安装MFC以及ATL这两项。

以下可能需要自备梯子

depot_tools安装

  • 获取depot_tools

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

depot_tools目录在D盘根目录上。

  • 将D:\depot_tools目录的路径加到System variables系统环境变量Path里,然后把该路径移到最前面(这个工具会下载自己的python和git,避免已安装冲突)。

  • 在User variables for Administration新建一个系统环境变量: DEPOT_TOOLS_WIN_TOOLCHAIN ,值设置为0,提示depot_tools使用本机的VS进行编译。

WebRTC源码

打开命令行窗口,在D盘新建个目录准备下载源代码,如下:

D:
mkdir webrtc-checkout
cd webrtc-checkout

在同一个命令行窗口里设置环境变量,你如果上面默认路径安装VS2019企业版,应该是一样的内容,其他版本相应修改下就好了。

set vs2019_install=C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise
set GYP_MSVS_OVERRIDE_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise
set GYP_GENERATORS=msvs-ninja,ninja

执行下面的命令开始下载代码,这是个漫长的过程,下载的文件总大小大概10G,包括源码以及一些测试的音视频文件资源等等。

fetch --nohooks webrtc
gclient sync

如果中途出错,那就继续运行 gclient sync 。
我这个挺顺利的,花了一夜时间,顺利完成。

编译

执行下面的命令,生成VS2019工程文件

cd src
gn gen --ide=vs out/Default

这一次报错了,提示如下:

Traceback (most recent call last):
File "D:/webrtc-checkout/src/build/compute_build_timestamp.py", line 127, in <module>
  sys.exit(main())
File "D:/webrtc-checkout/src/build/compute_build_timestamp.py", line 113, in main
  last_commit_timestamp = int(open(lastchange_file).read())
IOError: [Errno 2] No such file or directory: 'D:\webrtc-checkout\src\build\util\LASTCHANGE.committime'
ERROR at //build/timestamp.gni:31:19: Script returned non-zero exit code.
build_timestamp = exec_script(compute_build_timestamp,
       ^----------
Current dir: D:/webrtc-checkout/src/out/Default/
Command: D:/depot_tools/bootstrap-3_8_0_chromium_8_bin/python/bin/python.exe D:/webrtc-checkout/src/build/compute_build_timestamp.py default
Returned 1.
See //build/config/win/BUILD.gn:10:1: whence it was imported.
import("//build/timestamp.gni")
^-----------------------------
See //build/config/BUILDCONFIG.gn:446:5: which caused the file to be included.
"//build/config/win:default_crt",
^-------------------------------

执行下面的命令,就可以修复,注意检查src目录下的build\util\LASTCHANGE是否存在,没有就继续运行源代码下载。

D:\webrtc-checkout\src>python build\util\lastchange.py build\util\LASTCHANGE

再次运行

D:\webrtc-checkout\src>gn gen --ide=vs out/Default
Generating Visual Studio projects took 2261ms
Done. Made 1083 targets from 229 files in 20181ms

生成的项目文件是 D:\webrtc-checkout\src\out\Default 目录下的 all.sln ,可以用VS2019打开。放个图。

 

vs打开webrtc项目

 

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值