windows下面编译webrtc总是会遇到各种问题,花了不少的时间,是google的大牛们没考虑充分呢?还是我们自身环境配置问题?肯定是后者,我本人不是windows开发人员,工作完全在Linux环境下开发,所以可能遇到的问题应该会多一些。
下面这两个帖子不错,应该是可以解决大多数错误:
1) https://blog.csdn.net/counsellor/article/details/103344325
2)https://blog.csdn.net/Zurong_Lee/article/details/102222185?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-6.edu_weight&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-6.edu_weight
另外,还有几个问题需要注意:
(或许有些是我自己没解决,也或许你也遇不到)
- gclient 执行无响应,需要将gclient.bat里面python2对应的执行命令中vpython替换成python:
call python "%~dp0gclient.py" %*
- gclient runhooks没有响应,在gclient.py找到runhooks对应的函数,将vpython.bat -> vpython, vpython ->python. 也就是将下面的内容注释掉:
#if cmd[0] == 'python':
#cmd[0] = 'vpython'
#if cmd[0] == 'vpython' and _detect_host_os() == 'win':
#cmd[0] += '.bat'
- 编译时,cd到代码的C:\web_rtc\code\src路径下
- 在路径C:\web_rtc\code\src\build\util,创建LASTCHANGE.committime, 里面可以写上个时间,比如1605620771
- gclient runhooks有可能会卡在clang_format_win 和 rc_win,rc.exe 和 clang-format.exe的下载:
https://www.programmersought.com/article/59245820986/
======================2021421 update ===========================
6. 最近更新了一版webRTC代码,原来可以编译通过的版本,编译失败,gn命令执行也是失败的。错误如下:
ERROR at //build/config/python.gni:66:15: Could not execute interpreter.
_is_python2 = exec_script("//build/util/is_python2.py", [], "json")
^----------
I was trying to execute "python3".
See //third_party/closure_compiler/compile_js.gni:5:1: whence it was imported.
import("//build/config/python.gni")
^---------------------------------
See //third_party/protobuf/proto_library.gni:131:3: whence it was imported.
import("//third_party/closure_compiler/compile_js.gni")
^-----------------------------------------------------
See //BUILD.gn:20:3: whence it was imported.
import("//third_party/protobuf/proto_library.gni")
^------------------------------------------------
根据提示,exec_script这个函数在执行的时候,尝试调用python3,但是我本地环境下面没有安装python3, 而且环境变量GCLIENT_PY3 = 0。
后来安装了python3,也没有解决。
最后通过改 src/.gn文件可以解决,gn默认的是python3.
# The python interpreter to use by default. On Windows, this will look
# for python3.exe and python3.bat.
#script_executable = "python3"
script_executable = "python"
20211231 update=
- 换了电脑之后,gclient sync报了下面的错误:
gclient sync
Error: client not configured; see 'gclient config'
解决办法:
gclient config https://webrtc.googlesource.com/src.git
如果gclient runhooks失败,没办法下载gn, 可以手动下载
https://chrome-infra-packages.appspot.com/p/gn/gngclient sync error: "The system cannot find the file specified:
C:\Work\web_rtc\code\src>gclient sync
Traceback (most recent call last):
File "C:\Work\web_rtc\depot_tools\metrics.py", line 291, in print_notice_and_exit
yield
File "C:\Work\web_rtc\depot_tools\gclient.py", line 3242, in <module>
sys.exit(main(sys.argv[1:]))
File "C:\Work\web_rtc\depot_tools\gclient.py", line 3228, in main
return dispatcher.execute(OptionParser(), argv)
File "C:\Work\web_rtc\depot_tools\subcommand.py", line 252, in execute
return command(parser, args[1:])
File "C:\Work\web_rtc\depot_tools\gclient.py", line 2782, in CMDsync
ret = client.RunOnDeps('update', args)
File "C:\Work\web_rtc\depot_tools\gclient.py", line 1800, in RunOnDeps
self._CheckConfig()
File "C:\Work\web_rtc\depot_tools\gclient.py", line 1440, in _CheckConfig
actual_url = scm.GetActualRemoteURL(self._options)
File "C:\Work\web_rtc\depot_tools\gclient_scm.py", line 149, in GetActualRemoteURL
mirror = self.GetCacheMirror()
File "C:\Work\web_rtc\depot_tools\gclient_scm.py", line 138, in GetCacheMirror
if getattr(self, 'cache_dir', None):
File "C:\Work\web_rtc\depot_tools\gclient_scm.py", line 213, in cache_dir
return git_cache.Mirror.GetCachePath()
File "C:\Work\web_rtc\depot_tools\git_cache.py", line 196, in GetCachePath
['cache.cachepath']).decode('utf-8', 'ignore').strip()
File "C:\Python27\lib\subprocess.py", line 216, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "C:\Python27\lib\subprocess.py", line 394, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 644, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
解决办法, debug python脚本:
C:\Python27\python.exe -m pdb C:\Work\web_rtc\depot_tools\gclient.py sync
经过跟踪调试,在git_cache.py中更改一下内容:
#git_exe = 'git.bat' if sys.platform.startswith('win') else 'git'
git_exe = 'git'
- gn gen out/Default --ide=vs2019, 错误:
gn新版本有这个问题
C:\Work\web_rtc\code\src>gn gen out/Default --ide=vs2019
ERROR at //testing/gmock/BUILD.gn:9:1: Dependency not allowed.
source_set("gmock") {
^---------------------
The item //testing/gmock:gmock
can not depend on //third_party/googletest:gtest_config
because it is not in //third_party/googletest:gtest_config's visibility list: [
//third_party/googletest:*
]
解决办法:
/third_party/googletest/BUILD.gn, visibility = [ " : *" ] # gmock also shares this config.更改为:
visibility = [ "*" ] # gmock also shares this config.
20220426 update=
$ ninja -C out/Default
ninja: Entering directory `out/Default'
ninja: error: '../../third_party/dav1d/libdav1d/src/cdf.c', needed by 'obj/third_party/dav1d/dav1d/cdf.obj', missing and no known rule to make it
解决办法:
cd src/third_party/dav1d/libdav1d
git pull