这个错误表明您的系统没有检测到支持的 Visual Studio 版本(需要 VS2017 或 VS2019),但您已经指定了 --ide=vs2019
。以下是解决方案:
1. 确认 Visual Studio 安装
- 确保已安装 Visual Studio 2019,并包含以下组件:
- “使用 C++的桌面开发” 工作负载
- Windows 10 SDK (10.0.19041)
- 如果已安装但仍报错,尝试修复安装或运行:
$env:GYP_MSVS_VERSION = '2019' # 强制指定版本
2. 更新环境变量
在 PowerShell 中临时设置工具链路径(根据您的实际路径调整):
$env:VS2019_INSTALL_DIR = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
$env:PATH += ";$env:VS2019_INSTALL_DIR\VC\Tools\MSVC\<version>\bin\Hostx64\x64"
3. 检查 depot_tools
确保 depot_tools
已正确更新:
cd D:\webrtc\windows\webrtc\webrtc\depot_tools
git pull origin main
gclient sync
4. 重新生成构建配置
清理后重新生成(添加 --verbose
查看详细错误):
gn clean out/X64Debug
gn gen out/X64Debug --winsdk="10.0.19041" --ide=vs2019 --args='ffmpeg_branding=\"Chrome\" rtc_use_h264=true proprietary_codecs=true is_debug=true target_cpu=\"x64\"' --verbose
5. 备用方案
如果问题持续,尝试直接调用 vs_toolchain.py
调试:
python build/vs_toolchain.py get_toolchain_dir
观察输出是否正常返回 VS2019 路径。
⚠️ 注意:WebRTC Windows 编译对工具链版本敏感,建议严格遵循 官方文档的版本要求。
内容由零声教学AI助手提供,问题来源于学员提问