Compile WebRTC under Windows

created at 12-25-2021 views: 61

Install VSCode

We generally use IDE-Visual Studio to develop and debug programs under Windows. WebRTC also supports us to generate VS projects. The process of installing VS will not be repeated (it is recommended to install VS2017 or VS2019). It should be noted that the following three items must be checked when VS is installed:

  • Windows 10 SDK (10.0.18362) or above Windows 10 SDK (WebRTC source code of m84 version requires 10.0.18362 or above Windows 10 SDK).
  • Visual C++ ATL for x86 and x64.
  • Visual C++ MFC for x86 and x64.

Windows 10 SDK (10.0.18362) is not included in the VS2017 installation option. You can download it from the Win10 SDK, or install VS2019 directly.

After installing VS, you also need to install SDK debugging tools. the way is:

  • Open the Control Panel -> Programs and Features, find Windows Software Development Kit, right click the mouse -> Change.
  • Select Change in the opening interface, and click Next.
  • Check Debugging Tools For Windows and click Change.

Install depot_tools

git clone to get depot_tools

git clone
# Install the compilation tools on Windows

Configure the path of the depot_tools directory to the system environment variable Path, and set it to the top.

Download webrtc source code

mkdir webrtc-checkout
cd webrtc-checkout
fetch --nohooks webrtc
gclient sync

The latest source code is downloaded by default. If you want to switch to the specified branch, you can use the following command:

# View available version branches
git branch -r
# Switch to m79 branch
git checkout branch-heads/m79
gclient sync
# Or forcibly switch to the specified commit (b484ec0082948ae086c2ba4142b4d2bf8bc4dd4b is the last commit id submitted by m79)
gclient sync -r b484ec0082948ae086c2ba4142b4d2bf8bc4dd4b --force


# Set vs2017 environment variables
set vs2019_install=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community
set GYP_MSVS_OVERRIDE_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community

# Set vs2019 environment variables
set vs2019_install=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
set GYP_MSVS_OVERRIDE_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community

set GYP_GENERATORS=msvs-ninja,ninja
# Tell depot_tools to use our native VS to compile

# Compile vs2017 release:
gn gen out\Release-vs2017 --ide=vs2017 --args="is_debug=false target_os=\"win\" target_cpu=\"x64\" is_component_build=false is_clang=false use_lld=false treat_warnings_as_errors=false use_rtti=true rtc_include_tests =false rtc_build_examples=false"
ninja -C out\Release-vs2017

# Compile vs2019 release:
gn gen out\Release-vs2019 --ide=vs2019 --args="is_debug=false target_os=\"win\" target_cpu=\"x64\" is_component_build=false is_clang=false use_lld=false treat_warnings_as_errors=false use_rtti=true rtc_include_tests =false rtc_build_examples=false"
ninja -C out\Release-vs2019


  • Use python2 to compile!
  • Environment variables can also be set to the environment variables of the system.

After successful compilation, the `all.sln` solution file will be generated under src\out\xxxx\. You can debug the webrtc project by opening it. Generate the static library-webrtc.lib in the src\out\xxxx\obj directory, reference this static library in other projects and include related header files, and then you can use webrtc functions externally.

windows extract all header files of webrtc
Execute the following script in the src same-level directory of webrtc

echo off

:: Define source directory
set sourcePath=.\src
::Define the target path
set resulePath=.\include

xcopy %sourcePath%\*.h %resulePath%\ /s /e /c /y /r



1. Compile error in VS project

error LNK2038: Detected mismatch of "_ITERATOR_DEBUG_LEVEL": value "0" does not match value "2"


This error will only appear in the debug version. Add the compilation parameter enable_iterator_debugging=true in the compilation of debug.

More webrtc compilation parameter descriptions:

  • is_component_build: Whether to use the dynamic runtime library, set false to indicate the use of the static runtime library, the Release version will correspond to MT, and the Debug version will correspond to MTd.
  • proprietary_codecs: Whether to use copyright encoding, that is, H264.
  • rtc_use_h264: Whether to use H264. Note that the Windows platform uses OpenH264 for encoding and ffmpeg for decoding.
  • ffmpeg_branding: The branch name of ffmpeg, using the Chrome branch.
  • rtc_build_ssl: Whether to compile BoringSSL.
  • rtc_ssl_root: OpenSSL header file path will be written to the generated ninja file.
  • use_custom_libcxx: Whether to use the built-in libcxx as the default C++ standard library.
  • rtc_libvpx_build_vp9: Whether to support vp9 codec.
  • symbol_level: symbol level. Set to 0 to reduce the size of the library.


To compile webrtc to add H264 support, you need to add compile options


ffmpeg uses vc++ to compile and compile, so it must be forced to use clang.


To compile webrtc to use openssl, you need to add compile options

rtc_ssl_root="C:\Program Files\OpenSSL-Win64\include"
created at:12-25-2021
edited at: 12-27-2021: