在音视频领域,想深入研究的话,必定会接触WebRTC。WebRTC是一个庞大的工程,就像是音视频领域的百科全书,音视频采集,编解码,传输,渲染等一条龙在WebRTC里都有,而且WebRTC还有很多先进的音视频处理算法。由于WebRTC代码过于庞大,所以最好单步调试跟踪代码运行,这样才可以更好地学习WebRTC,否则很难有头绪。工欲善其事必先利其器,作为调试神器,宇宙第一IDE Visual Studio必不可少。所以本篇文章主要讲下如何在Windows上编译WebRTC,同时得到VS工程,然后调试。
很早以前写过VS2017上的编译,不过那篇文章有点跟不上时代,因为WebRTC用到的编译工具以及版本总是变化的,所以另开此文章,同步更新Windows平台最新编译步骤。
本文内容截止2024.08.23,最新代码测试编译通过
系统要求
- Win10及以上64位系统。
- 内存至少8G,当然越大越好。
- 至少100G磁盘空间(NTFS格式),不能是FAT32,因为会生成大于4G的文件。
Visual Studio安装
要求 Visual Studio 2022 (>=17.0.0)。这里我们选择VS2022的社区版。安装VS2012时选择自定义安装,必须勾选如下几项:
- Desktop development with C++组件中10.0.22621.0或以上的Win11 SDK(如果没看到该版本,去左侧Individual components那里勾选)
- Desktop development with C++组件中MFC以及ATL这两项
安装完VS2022后,必须安装SDK调试工具。打开控制面板->程序与功能,找到刚才安装的最新Windows Software Development Kit,鼠标右键->change。
勾选Debugging Tools For Windows,然后点击change。
depot_tools安装
下载depot_tools然后解压到某个目录,比我的解压到E盘根目录。接着将该depot_tools目录的路径加到系统环境变量Path里,然后把该路径移到最前面(避免已安装的python与git造成影响)。
或者直接通过如下命令行快速安装设置:
1 2 3 4 |
curl https://storage.googleapis.com/chrome-infra/depot_tools.zip --output depot_tools.zip mkdir e:\depot_tools tar -xf depot_tools.zip -C e:\depot_tools set PATH=e:\depot_tools;%PATH% |
获取WebRTC源码
由于WebRTC的源码地址被墙了,所以需要通过科学工具访问才能得到源码。后面都是命令行操作,打开cmd窗口,例如我用的是Clash代理,在cmd窗口设置如下:
1 2 |
set http_proxy=127.0.0.1:7890 set https_proxy=127.0.0.1:7890 |
设置当前cmd窗口代理上网,如果cmd窗口关闭了重开得重新设置。
接着执行gclient
命令,安装编译需要用到的一些工具,比如git以及python。
1 |
gclient |
再接着设置一些环境变量,设置下我们的VS安装路径以及Windows SDK路径,这里我是安装在C盘。由于我用的社区版,所以路径名后缀是Community,其他VS版本可按实际修改。
1 2 3 4 5 |
set vs2022_install=C:\Program Files (x86)\Microsoft Visual Studio\2022\Community set GYP_GENERATORS=msvs-ninja,ninja set WINDOWSSDKDIR=C:\Program Files (x86)\Windows Kits\10 # 告诉depot_tools使用我们本机的VS进行编译 set DEPOT_TOOLS_WIN_TOOLCHAIN=0 |
然后cd到要放源码的地方,执行:
1 2 3 4 5 6 |
mkdir webrtc-checkout cd webrtc-checkout # 生成.gclient文件 fetch --nohooks webrtc # 主要是根据DEPS文件下载第三方库 gclient sync |
这一过程是个漫长的等待,包括源码,第三方库,以及一些测试的音视频文件资源等,如果因为网络等原因中断了,就再执行gclient sync
。如果这一步一直卡着不动,可以执行ctrl+c
,然后执行gclient sync
。
编译工程
生成VS工程文件
首先需要生成工程文件。WebRTC默认使用Ninja作为编译系统,Ninja工程文件通过GN生成,由于我们需要使用VS进行代码编辑调试等,所以使用GN生成Ninja工程时需要配置--ide=vs
生成VS的工程文件。通过如下命令生成工程文件(Debug编译,工程文件位于out\Default
目录下):
1 2 |
cd src gn gen --ide=vs2022 out/Default |
我们可以在src\out\Default
下得到 VS2022的all.sln解决方案文件。
如果需要Release编译,通过如下命令生成工程文件:
1 |
gn gen --ide=vs2022 out/Default --args="is_debug=false" |
如果不想使用默认编译参数,可以使用
gn args out/Default --list
查看当前编译参数,通过类似如下方式设置:
1 gn gen --ide=vs2022 out/Default --args="use_rtti=true is_clang=false rtc_build_tools=false rtc_include_tests=false rtc_build_examples=false"
编译
生成工程文件后,就可以在src
目录下执行编译命令:
1 |
ninja -C out/Default |
用VS2022打开:
可以看到众多工程,到此算是完成了。找到我们感兴趣的,就可以用VS单步调试,跟踪代码运行了。
代码更新
后续如需要更新代码,按照如下步骤:
1 2 3 |
git checkout master git pull origin master gclient sync |
然后参考前面步骤重新生成工程文件,编译即可。
引用WebRTC库
WebRTC编译后会在src\out\Default\obj
目录下生成整个WebRTC工程的静态库:webrtc.lib,链接下这个就可以了。
PS:最新版只支持Clang编译器。
如果VS应用没配置Clang编译器,链接这个webrtc.lib,生成工程文件时需要配置如下参数:
gn gen --ide=vs out/Default --args="is_clang=false use_lld=false"
禁用clang与lld
总结
总之WebRTC在Windows上的编译很考验耐心,只要你的科学上网工具够好,编译就会顺畅很多。
如果遇到问题,可以多看下文章,是不是哪里漏了,或者看下评论,不要一上来就问为什么编译不了。
参考
[1] WebRTC Native code Development.https://webrtc.github.io/webrtc-org/native-code/development/.
[2] Chromium’s build instructions for Windows.https://chromium.googlesource.com/chromium/src/+/master/docs/windows_build_instructions.md.
文章评论
@jeff 大佬,求一份工程, 2749048950@qq.com
@annlee 依赖太多,还是靠自己编译吧
@Jeff 主要是翻墙更新太慢了,老断,下不下来,ss的老被禁,其他的还好
@annlee 推荐使用V-P-N再编译,我用的https://www.ex防止屏蔽pressv防止屏蔽pn.com/(去掉中间汉字) 这个,速度很快
@Jeff https://www.ex防止屏蔽pressv防止屏蔽pn.com/
这个打不开呢
@sss 这种网站肯定被屏蔽了
@Jeff ok
3Q作者,我也是今天在WIN下编译的:
遇到的坑全靠作者文章;
也是遇到vs_toolchain.py问题; cmd下set不太行,也懒得每次同步后改他py;
看了看他运行PY是os.env取;
我是在: 环境变量->系统变量->直接新建变量名:vs2019_install; 变量值:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise;解决;
@thank作者 不客气
D:\workspace\c++\opensource\other\webrtc-code\webrtc>gclient sync
kernel32.SetConsoleMode to enable ANSI sequences failed
Syncing projects: 100% ( 1/ 1) src
src (ERROR)
----------------------------------------
[0:00:00] Started.
[0:00:00]
Traceback (most recent call last):
File "E:\tools\depot_tools\gclient_scm.py", line 1043, in _Clone
self._Run(clone_cmd, options, cwd=self._root_dir, retry=True,
File "E:\tools\depot_tools\gclient_scm.py", line 1411, in _Run
gclient_utils.CheckCallAndFilter(cmd, env=env, **kwargs)
File "E:\tools\depot_tools\gclient_utils.py", line 634, in CheckCallAndFilter
show_header_if_necessary(needs_header, attempt)
File "E:\tools\depot_tools\gclient_utils.py", line 567, in show_header_if_necessary
stdout_write(header.encode())
File "E:\tools\depot_tools\third_party\colorama\ansitowin32.py", line 41, in write
self.__convertor.write(text)
File "E:\tools\depot_tools\third_party\colorama\ansitowin32.py", line 162, in write
self.write_and_convert(text)
File "E:\tools\depot_tools\third_party\colorama\ansitowin32.py", line 184, in write_and_convert
text = self.convert_osc(text)
File "E:\tools\depot_tools\third_party\colorama\ansitowin32.py", line 246, in convert_osc
for match in self.ANSI_OSC_RE.finditer(text):
TypeError: cannot use a string pattern on a bytes-like object
[0:00:01] _____ removing non-empty tmp dir D:\workspace\c++\opensource\other\webrtc-code\webrtc\_gcl
----------------------------------------
Traceback (most recent call last):
File "E:\tools\depot_tools\metrics.py", line 267, in print_notice_and_exit
yield
File "E:\tools\depot_tools\gclient.py", line 3195, in <module>
sys.exit(main(sys.argv[1:]))
File "E:\tools\depot_tools\gclient.py", line 3181, in main
return dispatcher.execute(OptionParser(), argv)
File "E:\tools\depot_tools\subcommand.py", line 252, in execute
return command(parser, args[1:])
File "E:\tools\depot_tools\gclient.py", line 2737, in CMDsync
ret = client.RunOnDeps('update', args)
File "E:\tools\depot_tools\gclient.py", line 1779, in RunOnDeps
work_queue.flush(revision_overrides, command, args, options=self._options,
File "E:\tools\depot_tools\gclient_utils.py", line 965, in flush
reraise(e[0], e[1], e[2])
File "E:\tools\depot_tools\gclient_utils.py", line 67, in reraise
raise value
File "E:\tools\depot_tools\gclient_utils.py", line 1042, in run
self.item.run(*self.args, **self.kwargs)
File "E:\tools\depot_tools\gclient.py", line 925, in run
self._got_revision = self._used_scm.RunCommand(command, options, args,
File "E:\tools\depot_tools\gclient_scm.py", line 132, in RunCommand
return getattr(self, command)(options, args, file_list)
File "E:\tools\depot_tools\gclient_scm.py", line 546, in update
self._Clone(revision, url, options)
File "E:\tools\depot_tools\gclient_scm.py", line 1043, in _Clone
self._Run(clone_cmd, options, cwd=self._root_dir, retry=True,
File "E:\tools\depot_tools\gclient_scm.py", line 1411, in _Run
gclient_utils.CheckCallAndFilter(cmd, env=env, **kwargs)
File "E:\tools\depot_tools\gclient_utils.py", line 634, in CheckCallAndFilter
show_header_if_necessary(needs_header, attempt)
File "E:\tools\depot_tools\gclient_utils.py", line 567, in show_header_if_necessary
stdout_write(header.encode())
File "E:\tools\depot_tools\third_party\colorama\ansitowin32.py", line 41, in write
self.__convertor.write(text)
File "E:\tools\depot_tools\third_party\colorama\ansitowin32.py", line 162, in write
self.write_and_convert(text)
File "E:\tools\depot_tools\third_party\colorama\ansitowin32.py", line 184, in write_and_convert
text = self.convert_osc(text)
File "E:\tools\depot_tools\third_party\colorama\ansitowin32.py", line 246, in convert_osc
for match in self.ANSI_OSC_RE.finditer(text):
TypeError: cannot use a string pattern on a bytes-like object
项目前面都有个红色图标,应该是有问题了吧?
@hyt_tony 应该是 git 状态,ignore
@hyt_tony Use
git status
to see what you have changed您好,我在生成工程文件的那一步一直遇到问题请问这种情况应该怎么办呀
E:\company\webrtc-checkout\src>gn gen --ide=vs out/Default
Traceback (most recent call last):
File "E:/company/webrtc-checkout/src/build/vs_toolchain.py", line 577, in <module>
sys.exit(main())
File "E:/company/webrtc-checkout/src/build/vs_toolchain.py", line 573, in main
return commands[sys.argv[1]](*sys.argv[2:])
File "E:/company/webrtc-checkout/src/build/vs_toolchain.py", line 387, in CopyDlls
_CopyRuntime(target_dir, runtime_dir, target_cpu, debug=True)
File "E:/company/webrtc-checkout/src/build/vs_toolchain.py", line 360, in _CopyRuntime
_CopyUCRTRuntime(target_dir, source_dir, target_cpu, suffix)
File "E:/company/webrtc-checkout/src/build/vs_toolchain.py", line 321, in _CopyUCRTRuntime
os.path.join(source_dir, 'ucrtbase' + suffix))
File "E:/company/webrtc-checkout/src/build/vs_toolchain.py", line 221, in _CopyRuntimeImpl
abs(os.stat(target).st_mtime - os.stat(source).st_mtime) >= 0.01)):
WindowsError: [Error 3] : 'C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.19041.0\\x64\\ucrt\\ucrtbased.dll'
ERROR at //build/toolchain/win/BUILD.gn:49:3: Script returned non-zero exit code.
exec_script("../../vs_toolchain.py",
^----------
Current dir: E:/company/webrtc-checkout/src/out/Default/
Command: D:/code/depot_tools/bootstrap-3_8_0_chromium_8_bin/python/bin/python.exe E:/company/webrtc-checkout/src/build/vs_toolchain.py copy_dlls E:/company/webrtc-checkout/src/out/Default Debug x64
Returned 1.
See //BUILD.gn:29:3: which caused the file to be included.
group("default") {
^-----------------
Traceback (most recent call last):
File "E:/company/webrtc-checkout/src/build/toolchain/win/setup_toolchain.py", line 304, in <module>
main()
File "E:/company/webrtc-checkout/src/build/toolchain/win/setup_toolchain.py", line 257, in main
vc_lib_um_path = FindFileInEnvList(env, 'LIB', ';', 'user32.lib')
File "E:/company/webrtc-checkout/src/build/toolchain/win/setup_toolchain.py", line 211, in FindFileInEnvList
file_name, env_name, '\n'.join(parts))
AssertionError: user32.lib is not found in LIB:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\ATLMFC\lib\x64
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\lib\x64
C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64
C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64
Check if it is installed.
@qsz 检查下Win10 SDK是否正确安装
@qsz @qsz 遇到了跟你一样么的问题,你的怎么解决了,求教,谢谢
看错误好像是找不到clang-cl.exe,用的哪个命令行工具?用VS自带的命令行执行看下。
@Jeff 现在遇到一个新的问题,我使用gn gen --ide=vs out/Default --args="use_rtti=true is_clang=false rtc_build_tools=false rtc_include_tests=false rtc_build_examples=false" 生成项目,并使用ninja -C out/Default来编译,有一个libyuv_internal项目总是编译不过,报错:
[2674/3292] CXX win_clang_x64/obj/third_party/libyuv/libyuv_internal/compare_win.obj
FAILED: win_clang_x64/obj/third_party/libyuv/libyuv_internal/compare_win.obj
..\..\third_party\llvm-build\Release+Asserts\bin\clang-cl.exe /nologo /showIncludes:user "-imsvcC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\ATLMFC\include" "-imsvcC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\include" "-imsvcC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-imsvcC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-imsvcC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared" "-imsvcC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um" "-imsvcC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt" "-imsvcC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt" -DHAVE_JPEG -DLIBYUV_DISABLE_MMI -DUSE_AURA=1 "-DCR_CLANG_REVISION=\"llvmorg-12-init-12923-g6ee22ca6-1\"" -D_HAS_NODISCARD -D_LIBCPP_ABI_UNSTABLE -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_ENABLE_NODISCARD -D_LIBCPP_DEBUG=0 -D_LIBCPP_NO_AUTO_LINK -D__STD_C -D_CRT_RAND_S -D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE -D_ATL_NO_OPENGL -D_WINDOWS -DCERT_CHAIN_PARA_HAS_EXTRA_FIELDS -DPSAPI_VERSION=2 -DWIN32 -D_SECURE_ATL -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -DWIN32_LEAN_AND_MEAN -DNOMINMAX -D_UNICODE -DUNICODE -DNTDDI_VERSION=NTDDI_WIN10_VB -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00 -D_DEBUG -DDYNAMIC_ANNOTATIONS_ENABLED=1 -I../.. -Iwin_clang_x64/gen -I../../third_party/libyuv/include -I../../third_party/libjpeg_turbo -fno-delete-null-pointer-checks -fcolor-diagnostics -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -mllvm -instcombine-lower-dbg-declare=0 -fcomplete-member-pointers /Gy /FS /bigobj /utf-8 /Zc:twoPhase /Zc:sizedDealloc- /X /D__WRL_ENABLE_FUNCTION_STATICS__ -fmsc-version=1916 -m64 -msse3 /Brepro -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -Xclang -fdebug-compilation-dir -Xclang . -no-canonical-prefixes /W4 -Wimplicit-fallthrough -Wunreachable-code -Wthread-safety -Wextra-semi /WX /wd4091 /wd4127 /wd4251 /wd4275 /wd4312 /wd4324 /wd4351 /wd4355 /wd4503 /wd4589 /wd4611 /wd4100 /wd4121 /wd4244 /wd4505 /wd4510 /wd4512 /wd4610 /wd4838 /wd4995 /wd4996 /wd4456 /wd4457 /wd4458 /wd4459 /wd4200 /wd4201 /wd4204 /wd4221 /wd4245 /wd4267 /wd4305 /wd4389 /wd4702 /wd4701 /wd4703 /wd4661 /wd4706 /wd4715 -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-unneeded-internal-declaration -Wno-undefined-var-template -Wno-nonportable-include-path -Wno-psabi -Wno-ignored-pragma-optimize -Wno-implicit-int-float-conversion -Wno-final-dtor-non-final-class -Wno-builtin-assume-aligned-alignment -Wno-deprecated-copy -Wno-non-c-typedef-for-linkage -Wmax-tokens /Od /Ob0 /GF /Z7 -gcodeview-ghash -Xclang -debug-info-kind=constructor -ftrivial-auto-var-init=pattern /guard:cf,nochecks /MTd -Xclang -add-plugin -Xclang find-bad-constructs -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare -Wno-trigraphs /TP /wd4577 -I../../buildtools/third_party/libc++/trunk/include /c ../../third_party/libyuv/source/compare_win.cc /Fowin_clang_x64/obj/third_party/libyuv/libyuv_internal/compare_win.obj /Fd"win_clang_x64/obj/third_party/libyuv/libyuv_internal_cc.pdb"
CreateProcess failed: The system cannot find the file specified.
ninja: fatal: ReadFile: 句柄无效。
使用vs2019单独编译libyuv_internal可以编译通过,但是奇怪的是,用vs单独编译后,继续执行ninja -C out/Default 还是会提示上面的报错
@Yoann 遇到了同样的问题 求博主解答~
@zack 我的解决了。
原因是一个clang-llvmorg-12-init-12923-g6ee22ca6-1.tgz的文件没有下载成功,可能是代理有问题。换了一下代码然后下载成功后,解压并将文件手动拷贝到src\third_party\llvm-build\Release+Asserts文件夹下,再次运行编译就可以了,请参考。
换了一下代理
set vs2019_install=D:\Program Files (x86)\Microsoft Visual Studio\2019\Community
set GYP_MSVS_OVERRIDE_PATH=D:\Program Files (x86)\Microsoft Visual Studio\2019\Community
set GYP_GENERATORS=msvs-ninja,ninja
set WINDOWSSDKDIR=D:\Windows Kits\10
tips: 第二行community多打了一个空格,直接复制的话会出现奇怪的错误...
PS: 如果Windows Software Development Kit安装不了Debugging Tools For Windows(我加载不了,开了VPN也没用)可以去官网下载 https://software-download.microsoft.com/download/pr/19041.685.201201-2105.vb_release_svc_prod1_WindowsSDK.iso 然后解压到路径:Windows Kits\10
@thanks 作者 安装到该路径...不是解压
怎么没有Desktop development with C++组件中10.0.19041或以上的Win10 SDK
Windows 10 SDK (10.0.18362.0) 只有这个可以吗?
vs2019 16.8.3的版本 好像自带的是10.0.18362.0, 不是10.0.19041。 必须要装10.0.19041 吗?
你们运行example 下peerconnection_client.exe 有没有遇到崩溃
#
# Fatal error in: ../../modules/video_capture/windows/sink_filter_ds.cc, line 724
# last system error: 0
# Check failed: (&capture_checker_)->IsCurrent()
#
@ziqzhang 检查摄像头是不是被占用了之类问题
我编译的m79版本,用VS2019打开会报错,
F:\git\webrtc_build_win\webrtc\src\modules/video_coding/codecs/h264/h264_color_space.h(20): fatal error C1189: #error: "See: bugs.webrtc.org/9213#c13."
好像是因为window上ffmpeg是用clang编译导致的
这个用什么办法解决呢?
@haige M79是2019年发布的版本,不适用这篇文章。编译M79时,
gclient
工具也得更新到对应日期时的版本。能不能提供一个.lib,一份include,这样我们不用这么麻烦也可以用webrtc了:)
@Fett 这个后续看下,编个原版的上传
生成vs工程,遇到这个错误,不知道该怎么办了
G:\webrtc\webrtc-checkout\src>gn gen out/default --ide=vs2017
Traceback (most recent call last):
File "G:/webrtc/webrtc-checkout/src/build/vs_toolchain.py", line 576, in <module>
sys.exit(main())
File "G:/webrtc/webrtc-checkout/src/build/vs_toolchain.py", line 572, in main
return commands[sys.argv[1]](*sys.argv[2:])
File "G:/webrtc/webrtc-checkout/src/build/vs_toolchain.py", line 387, in CopyDlls
_CopyDebugger(target_dir, target_cpu)
File "G:/webrtc/webrtc-checkout/src/build/vs_toolchain.py", line 423, in _CopyDebugger
(debug_file, full_path))
Exception: api-ms-win-downlevel-kernel32-l2-1-0.dll not found in "C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\api-ms-win-downlevel-kernel32-l2-1-0.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:49:3: Script returned non-zero exit code.
exec_script("../../vs_toolchain.py",
^----------
Current dir: G:/webrtc/webrtc-checkout/src/out/default/
Command: G:/depot_tools/bootstrap-3_8_0_chromium_8_bin/python/bin/python.exe G:/webrtc/webrtc-checkout/src/build/vs_toolchain.py copy_dlls G:/webrtc/webrtc-checkout/src/out/default Debug x64
Returned 1.
See //BUILD.gn:29:3: which caused the file to be included.
group("default") {
^-----------------
Traceback (most recent call last):
File "G:/webrtc/webrtc-checkout/src/build/toolchain/win/setup_toolchain.py", line 304, in <module>
main()
File "G:/webrtc/webrtc-checkout/src/build/toolchain/win/setup_toolchain.py", line 257, in main
vc_lib_um_path = FindFileInEnvList(env, 'LIB', ';', 'user32.lib')
File "G:/webrtc/webrtc-checkout/src/build/toolchain/win/setup_toolchain.py", line 211, in FindFileInEnvList
file_name, env_name, '\n'.join(parts))
AssertionError: user32.lib is not found in LIB:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64
C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\ucrt\x64
C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64
Check if it is installed.
@feifei 找到原因了,You must installWindows 10 SDK version 10.0.19041.0 including the "Debugging Tools for Windows" feature.
我下载的是vs2017,所以windows sdk是10.0.17.17134
实际生成sln时,找的却是10.0.17.19041的sdk,这是vs2019用的sdk, 猜测可能现在webrtc默认是vs2019,或者我有某个地方没设置对吧
重新单独下载了19041的sdk,安装后,再gn gen out/default --ide=vs2017 然后就生成成功了
请问gclient 如下错误是什么原因呢
Rebase produced error output:
fatal: Does not point to a valid commit '3ee03ddfde253208e6ae8b2e8debc459cd7d5393'
@john 执行什么操作导致?
@Jeff 就是按你的操作到gclient sync 那一步,不知道是不是网络原因,中断之后再执行gclient sync 也不行,卡在这里,我用的自己的vpn
@john
fetch --nohooks webrtc
确定前面这一步正确执行了?@Jeff 其实应该是fetch --nohooks webrtc 这一步开始中断的, 但是按照提示,这一步中断了,应该是继续执行gclient sync继续, 其实前面fetch这一步 就是这个错误提示 完整的大概像这样,看起来像是卡在同步src/tools这个文件里的内容
E:\study\audio\algorithm\webrtc\checkout>gclient sync
Syncing projects: 17% ( 7/41) src/tools
src/testing (ERROR)
----------------------------------------
[0:00:01] Started.
[0:00:04] _____ src\testing : Attempting rebase onto ca81cc1c2148cc6fb62dd4139f2dc7a19301d66a...
[0:00:04]
[0:00:04] Rebase produced error output:
fatal: Does not point to a valid commit 'ca81cc1c2148cc6fb62dd4139f2dc7a19301d66a'
----------------------------------------
Error: 5> Unrecognized error, please merge or rebase manually.
5> cd E:\study\audio\algorithm\webrtc\checkout\src\testing && git rebase --onto ca81cc1c2148cc6fb62dd4139f2dc7a19301d66a refs/remotes/origin/master
E:\study\audio\algorithm\webrtc\checkout>
@john
fetch --nohooks webrtc
这步出问题,后面肯定会执行失败啊,也就是Rebase这个错误能帮忙看看为什么会出现权限问题吗
E:\webrtc-checkout\src>ninja -C out\Default
ninja: Entering directory `out\Default'
[3/5171] LIB obj/api/neteq_simulator_api.lib
FAILED: obj/api/neteq_simulator_api.lib
ninja -t msvc -e environment.x64 -- ..\..\third_party\llvm-build\Release+Asserts
\bin\lld-link.exe /lib /nologo -libpath:..\..\third_party\llvm-build\Release+Ass
erts\lib\clang\13.0.0\lib\windows "-libpath:D:\Program Files (x86)\Microsoft Vis
ual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\ATLMFC\lib\x64" "-libpath:D:
\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.
29333\lib\x64" "-libpath:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um
\x64" "-libpath:D:\Windows Kits\10\lib\10.0.19041.0\ucrt\x64" "-libpath:D:\Windo
ws Kits\10\lib\10.0.19041.0\um\x64" "-libpath:D:\Program Files (x86)\Microsoft V
isual Studio 14.0\VC\lib" /ignore:4221 /llvmlibthin /OUT:obj/api/neteq_simulator
_api.lib @obj/api/neteq_simulator_api.lib.rsp
obj/api/neteq_simulator_api.lib: permission denied
lld-link: error: lib failed
[12/5171] CXX obj/common_audio/common_audio/real_fourier_ooura.obj
ninja: build stopped: subcommand failed.
@lee 前面的步骤已经成功了gn gen --ide=vs out/Default,生成了all.sln,最后一步ninja编译失败,头大
@lee 是不是你的杀毒软件什么造成的?
@Jeff 360卫士和杀毒的都是退出了
楼主您好,我在执行 ninja -C out/Default这个编译命令的时候 反复报这种错误会是什么原因导致的呢
In file included from ../../call/fake_network_pipe_unittest.cc:19:
In file included from ../..\test/gmock.h:17:
In file included from ../..\testing/gmock/include/gmock/gmock.h:10:
In file included from ../..\third_party/googletest/src/googlemock/include/gmock/gmock.h:61:
In file included from ../../third_party/googletest/src/googlemock/include\gmock/gmock-function-mocker.h:4:
In file included from ../../third_party/googletest/src/googlemock/include\gmock/gmock-generated-function-mockers.h:47:
../../third_party/googletest/src/googlemock/include\gmock/gmock-spec-builders.h(1256,44): error: call to implicitly-deleted copy constructor of 'testing::internal::MockSpec<webrtc::PacketReceiver::DeliveryStatus (webrtc::MediaType, rtc::CopyOnWriteBuffer, long long)>::ArgumentMatcherTuple' (aka 'tuple<Matcher<webrtc::MediaType>, Matcher<rtc::CopyOnWriteBuffer>, Matcher<long long> >')
: function_mocker_(function_mocker), matchers_(matchers) {}
^ ~~~~~~~~
../../third_party/googletest/src/googlemock/include\gmock/gmock-spec-builders.h(1600,12): note: in instantiation of member function 'testing::internal::MockSpec<webrtc::PacketReceiver::DeliveryStatus (webrtc::MediaType, rtc::CopyOnWriteBuffer, long long)>::MockSpec' requested here
return MockSpec<F>(this, ::std::make_tuple(std::move(m)...));
^
../../call/fake_network_pipe_unittest.cc(28,3): note: in instantiation of member function 'testing::internal::FunctionMocker<webrtc::PacketReceiver::DeliveryStatus (webrtc::MediaType, rtc::CopyOnWriteBuffer, long long)>::With' requested here
MOCK_METHOD3(DeliverPacket,
^
../../third_party/googletest/src/googlemock/include\gmock/gmock-generated-function-mockers.h(602,30): note: expanded from macro 'MOCK_METHOD3'
#define MOCK_METHOD3(m, ...) GMOCK_METHOD3_(, , , m, __VA_ARGS__)
^
../../third_party/googletest/src/googlemock/include\gmock/gmock-generated-function-mockers.h(237,48): note: expanded from macro 'GMOCK_METHOD3_'
return GMOCK_MOCKER_(3, constness, Method).With(gmock_a1, gmock_a2, \
^
..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\tuple(351,5): note: copy constructor is implicitly deleted because 'tuple<testing::Matcher<webrtc::MediaType>, testing::Matcher<rtc::CopyOnWriteBuffer>, testing::Matcher<long long> >' has a user-declared move constructor
tuple(tuple&&) = default;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
ninja: build stopped: subcommand failed.
@xiaoyu 看起来代码问题,你更新最新WebRTC代码看下
gclient sync同步代码的时候遇到这种情况中断掉了,这啥情况
Syncing projects: 17% ( 7/41) src/tools
src/buildtools (ERROR)
----------------------------------------
[0:00:00] Started.
[0:00:02] _____ src\buildtools : Attempting rebase onto 368c7dd2c90cd27cadfa8e653ab6953405f153cc...
[0:00:03]
[0:00:03] Rebase produced error output:
fatal: Does not point to a valid commit '368c7dd2c90cd27cadfa8e653ab6953405f153cc'
----------------------------------------
Error: 4> Unrecognized error, please merge or rebase manually.
4> cd C:\QyMessage\webrtc\code3\src\buildtools && git rebase --onto 368c7dd2c90cd27cadfa8e653ab6953405f153cc refs/remotes/origin/master
@Jeff 楼主能否烦请发我一份编译好的VS工程包,非常感谢!邮箱m15302252829@163.com
生成的是webrtc.lib,应该没办法在vs里面单步调试吧
Syncing projects: 16% ( 7/42) src/testing
src/tools (ERROR)
----------------------------------------
[0:00:00] Started.
[0:00:00] Finished running: git config remote.origin.url
[0:00:00] Finished running: git rev-list -n 1 HEAD
[0:00:00] Finished running: git rev-parse --abbrev-ref=strict HEAD
error: Server does not allow request for unadvertised object f903bb869e9a2e4274ee8eed90abfb04c0b7bb01
[0:00:06] error: Server does not allow request for unadvertised object f903bb869e9a2e4274ee8eed90abfb04c0b7bb01
[0:00:08] error: Server does not allow request for unadvertised object f903bb869e9a2e4274ee8eed90abfb04c0b7bb01
[0:00:12] error: Server does not allow request for unadvertised object f903bb869e9a2e4274ee8eed90abfb04c0b7bb01
----------------------------------------
Error: Command 'git -c core.deltaBaseCacheLimit=2g fetch origin f903bb869e9a2e4274ee8eed90abfb04c0b7bb01 --no-tags' returned non-zero exit status 128 in E:\project\webrtc-checkout\src\tools
博主有见过这个问题吗
请问楼主, 如何生成webrtc的动态库啊? 使用哪个参数可以做到?
不管是按照博主的做法还是按照声网的做法,每次到执行gclient是总是error,fatal,真是tm太难了,我连源码都下不来,好气啊
@难死了 建议按照这种方式下载编译; https://zhuanlan.zhihu.com/p/357634816
@Jeff,我编译后,运行peerconnection_server 和 peerconnection_client例子,发现peerconnection_client并没有弹出peer列表,请教这是什么问题?
[3224/5825] ACTION //third_party/boringssl:boringssl_asm_action(//build/toolchain/win:win_clang_x64)
FAILED: obj/third_party/boringssl/boringssl_asm/md5-x86_64.o
E:/studysoftware/depot_tools/bootstrap-2@3_8_10_chromium_23_bin/python3/bin/python3.exe ../../build/gn_run_binary.py nasm.exe -fwin64 -I./ -I../../ -Igen/ -MD obj/third_party/boringssl/boringssl_asm/md5-x86_64.o.d -o obj/third_party/boringssl/boringssl_asm/md5-x86_64.o ../../third_party/boringssl/win-x86_64/crypto/fipsmodule/md5-x86_64.asm
'.' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
nasm.exe failed with exit code 1
[3225/5825] CC obj/third_party/opus/opus/x86_celt_map.obj
ninja: build stopped: subcommand failed.
请问有博主见过这个问题吗
请问是否在windows下调试过webrtc?
麻烦问一下,我在src文件夹下,运行gn gen --ide=vs2017 out/Default,没有任何相应,out文件夹倒是生成了,但是是个空文件夹,这是什么情况?
环境变量我都配置过了,vs用的2017,sdk也有,ninja也安装了。
请问怎么生成pdb文件?
目前只能在webrtc的examples项目中调试,如果有pdb文件,就可以在其他使用webrtc的项目里断点调试了,请指教,谢谢
我在做完gclient sync后会报错,FileNotFoundError: [Errno 2] No such file or directory: 'F:\\webrtc\\webrtc-checkout\\src\\third_party'受累问一下这是怎么回事?
@虫儿恋夏 多试几次 看你这个应该没下载成功
C:\zzq\webrtc\webrtc-checkout\src\third_party>git diff
diff --git a/blink/web_tests/images/resources/missing-plte-before-trns.png b/blink/web_tests/images/resources/missing-plte-before-trns.png
deleted file mode 100644
index 96b6667effd..00000000000
Binary files a/blink/web_tests/images/resources/missing-plte-before-trns.png and /dev/null differ
C:\zzq\webrtc\webrtc-checkout\src\third_party>
这个错误没事吧。一下载就被安全工具删除了
setup_toolchain.py 需要改变这个文件里的SDK_VERSION = '10.0.20348.0'
@ziqzhang 默认下载下来是10.0.22621.0.所以要最新的sdk版本
In file included from ../..\rtc_base/platform_thread_types.h:20:
In file included from ../../../../../../Program Files (x86)/Windows Kits/10/include/10.0.20348.0/um\winsock2.h:53:
In file included from ../../../../../../Program Files (x86)/Windows Kits/10/include/10.0.20348.0/um\windows.h:172:
In file included from ../../../../../../Program Files (x86)/Windows Kits/10/include/10.0.20348.0/um\winbase.h:43:
In file included from ../../../../../../Program Files (x86)/Windows Kits/10/include/10.0.20348.0/um\fileapifromapp.h:20:
../../../../../../Program Files (x86)/Windows Kits/10/include/10.0.20348.0/um\fileapi.h(1065,10): error: unknown type name 'FILE_INFO_BY_HANDLE_CLASS'
_In_ FILE_INFO_BY_HANDLE_CLASS FileInformationClass,
编译报这错误 有没有遇到过?
@ziqzhang 最新代码 需要的sdk版本不一样 现在需要10.0.22621.755 下载链接https://developer.microsoft.com/en-us/windows/downloads/sdk-archive/
4117 /D__DATE__= /D__TIME__= /D__TIMESTAMP__= /Od /Ob0 /GF /Zi /MTd /wd4702 /wd5041 /std:c++20 /TP /GR- /Fd"obj/examples/stun_prober_cc.pdb"
c:\zzq\webrtc\webrtc-checkout\src\rtc_base/stream.h(111): error C2220: the following warning is treated as an error
c:\zzq\webrtc\webrtc-checkout\src\rtc_base/stream.h(111): warning C4068: unknown pragma 'clang'
c:\zzq\webrtc\webrtc-checkout\src\rtc_base/stream.h(112): warning C4068: unknown pragma 'clang'
c:\zzq\webrtc\webrtc-checkout\src\rtc_base/stream.h(120): warning C4068: unknown pragma 'clang' 现在编译有这错误, 有没有什么建议
c:\zzq\webrtc\src>gclient sync
Updating depot_tools...
using C:\Users\ziqzhang\AppData\Local\Temp\goma as tmpdir
compiler_proxy is not running
Error: client not configured; see 'gclient config'
c:\zzq\webrtc\src>gclient config https://webrtc.googlesource.com/src.git
或者重新走一遍 1.一个环境准备 2019 以及windows sdk(10.0.22621.755 下载最新的) 等等
2. 下载代码
gclient
mkdir webrtc-checkout
cd webrtc-checkout
fetch --nohooks webrtc
gclient sync
3.编译gn gen out/Default ninja -C out/Default
如果还是有问题 保证环境配置好 重启电脑
然后 Click on Start Menu → Visual Studio 2019 → x64 Native Tools Command Prompt for VS 2019
然后重新下载代码
@ziqzhang 默认下载下来是10.0.22621.0.所以要最新的sdk版本?
我想用以前的SDK,VS2017, 怎么办? 改webrtc 源码版本吗?
D:\webrtc\webrtc_new\webrtc-checkout\src>gn gen out/Default --ide=vs2017
ERROR at //build/config/compiler/BUILD.gn:1520:22: Script returned non-zero exit code.
clang_revision = exec_script("//tools/clang/scripts/update.py",
^----------
Current dir: D:/webrtc/webrtc_new/webrtc-checkout/src/out/Default/
Command: D:/webrtc/webrtc_new/depot_tools/bootstrap-2@3_8_10_chromium_26_bin/python3/bin/python3.exe D:/webrtc/webrtc_new/webrtc-checkout/src/tools/clang/scripts/update.py --print-revision --verify-version=17
Returned 1 and printed out:
The expected clang version is llvmorg-17-init-12166-g7586aeab-3 but the actual version is
Did you run "gclient sync"?
See //build/config/BUILDCONFIG.gn:337:3: which caused the file to be included.
"//build/config/compiler:compiler",
^---------------------------------
Traceback (most recent call last):
File "D:/webrtc/webrtc_new/webrtc-checkout/src/build/compute_build_timestamp.py", line 137, in <module>
sys.exit(main())
File "D:/webrtc/webrtc_new/webrtc-checkout/src/build/compute_build_timestamp.py", line 111, in main
last_commit_timestamp = int(open(lastchange_file).read())
FileNotFoundError: [Errno 2] No such file or directory: 'D:\\webrtc\\webrtc_new\\webrtc-checkout\\src\\build\\util\\LASTCHANGE.committime'
Traceback (most recent call last):
File "D:/webrtc/webrtc_new/webrtc-checkout/src/build/toolchain/win/setup_toolchain.py", line 316, in <module>
main()
File "D:/webrtc/webrtc_new/webrtc-checkout/src/build/toolchain/win/setup_toolchain.py", line 274, in main
env = _LoadToolchainEnv(cpu, toolchain_root, win_sdk_path, target_store)
File "D:/webrtc/webrtc_new/webrtc-checkout/src/build/toolchain/win/setup_toolchain.py", line 190, in _LoadToolchainEnv
return _ExtractImportantEnvironment(variables)
File "D:/webrtc/webrtc_new/webrtc-checkout/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\shared" from environment variable "include" does not exist. Make sure the necessary SDK is installed.
同步完成了,ConnectionResetError: [WinError 10054] 是什么原因?
D:\webrtc\webrtc_new\webrtc-checkout\src>gclient sync
Syncing projects: 100% (44/44), done.
________ running 'python3 src/tools/clang/scripts/update.py' in 'D:\webrtc\webrtc_new\webrtc-checkout'
Downloading https://commondatastorage.googleapis.com/chromium-browser-clang/Win/clang-llvmorg-17-init-12166-g7586aeab-3.tar.xz .........Traceback (most recent call last):
File "src/tools/clang/scripts/update.py", line 380, in <module>
sys.exit(main())
File "src/tools/clang/scripts/update.py", line 376, in main
return UpdatePackage(args.package, args.host_os, output_dir)
File "src/tools/clang/scripts/update.py", line 288, in UpdatePackage
DownloadAndUnpackPackage(package_file, dir, host_os)
File "src/tools/clang/scripts/update.py", line 198, in DownloadAndUnpackPackage
DownloadAndUnpack(cds_full_url, output_dir)
File "src/tools/clang/scripts/update.py", line 166, in DownloadAndUnpack
DownloadUrl(url, f)
File "src/tools/clang/scripts/update.py", line 120, in DownloadUrl
chunk = response.read(CHUNK_SIZE)
File "D:\webrtc\webrtc_new\depot_tools\bootstrap-2@3_8_10_chromium_26_bin\python3\bin\lib\http\client.py", line 455, in read
n = self.readinto(b)
File "D:\webrtc\webrtc_new\depot_tools\bootstrap-2@3_8_10_chromium_26_bin\python3\bin\lib\http\client.py", line 499, in readinto
n = self.fp.readinto(b)
File "D:\webrtc\webrtc_new\depot_tools\bootstrap-2@3_8_10_chromium_26_bin\python3\bin\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
File "D:\webrtc\webrtc_new\depot_tools\bootstrap-2@3_8_10_chromium_26_bin\python3\bin\lib\ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "D:\webrtc\webrtc_new\depot_tools\bootstrap-2@3_8_10_chromium_26_bin\python3\bin\lib\ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)
ConnectionResetError: [WinError 10054] ����������������������������������
Error: Command 'python3 src/tools/clang/scripts/update.py' returned non-zero exit status 1 in D:\webrtc\webrtc_new\webrtc-checkout
Downloading https://commondatastorage.googleapis.com/chromium-browser-clang/Win/clang-llvmorg-17-init-12166-g7586aeab-3.tar.xz .........Traceback (most recent call last):
File "src/tools/clang/scripts/update.py", line 380, in <module>
D:\webrtc\webrtc_new\webrtc-checkout\src>gn gen out/Default --ide=vs2017
gn.py: Could not find gn executable at: D:\webrtc\webrtc_new\webrtc-checkout\src\buildtools\win\gn.exe
gclient sync 没有问题。 用vs2022 + 最新SDK 有问题,请教一下大佬,什么原因。
@apachexc 你好,我也在使用vs2022下出了同样的问题,请问您解决了吗。
你好,我生成vs2019的工程,编译后能生成exe,也能执行,但是无法断点调试,你遇到过这种情况吗?首次打开vs2019能生成,改了后就无法生成,提示写入pdb错误。
fatal: unable to access 'https://chromium.googlesource.com/chromium/tools/depot_tools.git/': Failed to connect to chromium.googlesource.com port 443 after 21117 ms: Couldn't connect to server
您好,我编译成功了,但是我打开peerconnection_server.exe和peerconnection_client.exe,想要连接到服务器时,却连接不上。我尝试了重新编译,依然还是不行;“Failed to connect to localhost”
@HYZ 佬解决没
您好作者!
您的分享干货满满,但是在生成文件工程的时候,出现了问题
Windows SDK >= 10.0.22621.2428 required. You can get it by updating Visual Studio 2022 using the Visual Studio Installer.
ERROR at //build/config/win/visual_studio_version.gni:29:7: Script returned non-zero exit code.
但是我的SDK版本应该是没有问题的 选择的是SDK 11 但是他还是提示如此,不知道作者您是否知道解决方案?
@PowerBear 卸载winSDK, 重新安装 10.0.22621.2428
你好作者,感谢您分享的教程,但是在执行如下编译命令:
gn gen --ide=vs2022 out/Default
的时候遇到了如下问题:
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",
想问问这是什么原因的报错
FAILED: py_quality_assessment/quality_assessment/fake_polqa.exe py_quality_assessment/quality_assessment/fake_polqa.exe.pdb
"C:/Users/Administrator/AppData/Local/.vpython-root/store/python_venv-ugraqihfukp4j3cqs9pta4mias/contents/Scripts/python3.exe" ../../build/toolchain/win/tool_wrapper.py link-wrapper environment.x64 False link.exe "/OUT:py_quality_assessment/quality_assessment/fake_polqa.exe" /nologo "/PDB:py_quality_assessment/quality_assessment/fake_polqa.exe.pdb" "@py_quality_assessment/quality_assessment/fake_polqa.exe.rsp"
LINK : fatal error LNK1104: 无法打开文件“comdlg32.lib”
[1034/5803] LIB obj/api/rtp_parameters.lib
ninja: build stopped: subcommand failed.
===================
出现这错误,怎么处理呢?
请问,编译没有报错,但是peerconnection example跑不通是为啥,系统有server进城了,但是客户端无法连接
@Kris https://blog.csdn.net/qq_37176721/article/details/143835971?spm=1001.2014.3001.5502
要让webrtc支持h264编码器,需要怎么做? 最新版webrtc如果设置is_clang=false就会报错,