This document describes the tools, requirements, and patches needed to build libwebrtc from source on Windows for Qt project integration.
| Tool | Version | Purpose |
|---|---|---|
| Visual Studio 2022/2026 | Community+ | C++ compiler (MSVC cl.exe) |
| Git | Latest | Source control |
| Python | 3.x | Build scripts |
| depot_tools | Latest | Google's build toolchain |
Install via Visual Studio Installer:
- Desktop development with C++
- C++ Clang tools for Windows (for clang-cl)
- Windows 10/11 SDK
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
set PATH=%PATH%;C:\path\to\depot_toolsset DEPOT_TOOLS_WIN_TOOLCHAIN=0IMPORTANT:
DEPOT_TOOLS_WIN_TOOLCHAIN=0forces use of local MSVC toolchain instead of Google's internal toolchain.
mkdir webrtc_checkout
cd webrtc_checkout
fetch --nohooks webrtc
gclient syncDownload is ~20GB. This may take 1-2 hours depending on connection speed.
File: src/build/vs_toolchain.py
Add VS 2026 to supported versions:
MSVS_VERSIONS = {
'2022': 'toolchain_is_2022',
'2026': 'toolchain_is_2022', # Added
}
MSVC_TOOLSET_VERSION = {
# ...
'VC145': 'VC145', # Added for VS 2026
}
MSVS_FOLDER_NAMES = {
'2022': '2022',
'2026': '18', # Added
}File: src/build/config/win/BUILD.gn
Problem: WebRTC defaults to /MT (static CRT), Qt uses /MD (dynamic CRT).
Solution (around line 527):
config("default_crt") {
if (is_component_build) {
configs = [ ":dynamic_crt" ]
} else {
if (current_os == "winuwp") {
configs = [ ":dynamic_crt" ]
} else {
- # Desktop Windows: static CRT.
- configs = [ ":static_crt" ]
+ # Desktop Windows: Use dynamic CRT for Qt compatibility.
+ configs = [ ":dynamic_crt" ]
}
}
}cd src
gn gen out/Release_ClangMSVC --args="is_debug=false rtc_include_tests=false treat_warnings_as_errors=false use_custom_libcxx=false use_rtti=true target_cpu=\"x64\""| Argument | Value | Purpose |
|---|---|---|
is_debug |
false |
Release build |
rtc_include_tests |
false |
Skip test targets |
treat_warnings_as_errors |
false |
Ignore warnings |
use_custom_libcxx |
false |
Use MSVC STL instead of libc++ |
use_rtti |
true |
Enable RTTI for Qt compatibility |
target_cpu |
"x64" |
64-bit build |
ninja -C out/Release_ClangMSVC webrtcBuild produces: out/Release_ClangMSVC/obj/webrtc.lib (~365 MB)
copy out\Release_ClangMSVC\obj\webrtc.lib C:\path\to\project\libs\webrtc\lib\
robocopy src\api libs\webrtc\include\api /E /XD tests test
robocopy src\rtc_base libs\webrtc\include\rtc_base /E /XD tests test
robocopy src\third_party\abseil-cpp\absl libs\webrtc\include\absl /Eif(MSVC)
set(WEBRTC_ROOT "${CMAKE_SOURCE_DIR}/libs/webrtc")
set(WEBRTC_LIBRARY "${WEBRTC_ROOT}/lib/webrtc.lib")
add_compile_definitions(
WEBRTC_WIN
NOMINMAX
WIN32_LEAN_AND_MEAN
)
target_link_libraries(${PROJECT_NAME} PRIVATE
${WEBRTC_LIBRARY}
ws2_32 crypt32 secur32 winmm
dmoguids wmcodecdspuuid amstrmid msdmo strmiids
iphlpapi d3d11 dxgi
)
endif()Error: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease'
Cause: WebRTC built with /MT, project expects /MD.
Solution: Apply Patch 2 (dynamic CRT) and rebuild WebRTC.
Cause: Pure MSVC (is_clang=false) fails with compiler-rt.
Solution: Use clang-cl (default) with use_custom_libcxx=false.
These are harmless warnings from WebRTC headers. They can be suppressed with:
if(MSVC)
add_compile_options(/wd4068) # Suppress unknown pragma
endif()| Component | Tested Version |
|---|---|
| Windows | 10/11 |
| Visual Studio | 2022, 2026 |
| Qt | 6.10.2 |
| WebRTC | m131+ |
| OpenSSL | 3.6.1 |