webrtc windows编译记录

//cmd
set path=D:\zzh\depot_tools;%path%
set DEPOT_TOOLS_WIN_TOOLCHAIN 0
set vs2022_install=C:\Program Files\Microsoft Visual Studio\2022\Community

//powershell
$Env:PATH = "D:\zzh\depot_tools;$Env:PATH"
$env:DEPOT_TOOLS_WIN_TOOLCHAIN=0
$env:vs2019_install="C:\Program Files\Microsoft Visual Studio\2019\Community"

//vpn
$env:HTTP_PROXY="http://127.0.0.1:33210"
$env:HTTPS_PROXY="http://127.0.0.1:33210"
$env:all_proxy="socks5://127.0.0.1:33211"
export https_proxy=http://127.0.0.1:33210 http_proxy=http://127.0.0.1:33210 all_proxy=socks5://127.0.0.1:33211

src下面执行

gn gen 目录
ninja -c 目录

args.gn

rtc_build_tools = false
treat_warnings_as_errors = false
use_rtti = true
is_clang = false
target_cpu = "x64"
is_debug = true
symbol_level  = 2
target_os = "win"
uenable_libaom = false
enable_libaom_decoder = false
rtc_use_h264 = false
rtc_enable_protobuf = false
rtc_include_ilbc = false
rtc_libvpx_build_vp9 = false
rtc_include_tests = false 
enable_iterator_debugging = true 
rtc_build_examples = false
rtc_enable_avx2 = false
libcxx_abi_unstable = false
use_custom_libcxx_for_host = false
use_custom_libcxx = false

1. 问题:

1.1 LNK2038 检测到“_ITERATOR_DEBUG_LEVEL”的不匹配项: 值“0”不匹配值“2”(RTCRoomImpl.obj 中) XWRtc D:\XWRTC\client\windows\XWRtcWinDemo\XWRtc\libcpmtd0.lib(xgetwctype.obj) 1

_ITERATOR_DEBUG_LEVEL不匹配的解决方案就是在Debug版本的args.gn中写入enable_iterator_debugging=true参数,然后再执行gn gen out/Debug重新生成文件,再调用ninja编译就可以了。

1.2 LNK2005 "protected: char * __cdecl std::basic_streambuf<char,struct std::char_traits >::eback(void)const " (?eback@?\(basic_streambuf@DU?\)char_traits@D@std@@@std@@IEBAPEADXZ) 已经在 webrtc.lib(int128.obj) 中定义 XWRtc D:\XWRTC\client\windows\XWRtcWinDemo\XWRtc\msvcprtd.lib(MSVCP140D.dll) 1

修改文件

src\build\config\win\BUILD.gn

中static_crt如下

config("static_crt") {
  if (is_debug) {
    # This pulls in the static debug CRT and defines _DEBUG
    cflags = [ "/MDd" ]
    if (use_custom_libcxx) {
      ldflags = [ "/DEFAULTLIB:libcpmtd.lib" ]
    }
  } else {
    cflags = [ "/MD" ]
    if (use_custom_libcxx) {
      ldflags = [ "/DEFAULTLIB:libcpmt.lib" ]
    }
  }

cflags = [ "/MDd", "/Z7" ]

1.3 预编译宏

NOMINMAX
WIN32_LEAN_AND_MEAN
WEBRTC_WIN
_CRT_SECURE_NO_WARNINGS
WIN32

严重性 代码 说明 项目 文件 行 禁止显示状态
错误 LNK2001 无法解析的外部符号 CRYPTO_refcount_inc XWRtc D:\XWRTC\client\windows\XWRtcWinDemo\XWRtc\webrtc.lib(encrypted_client_hello.obj) 1

https://cloud.tencent.com/developer/article/1960512

D:\zzh\webrtc\src\third_party\boringssl\src>
-#if defined(OPENSSL_C11_ATOMIC)
+#if defined(OPENSSL_C11_ATOMIC)// && !defined(_MSC_VER)

USE_AURA=1;_HAS_EXCEPTIONS=0;__STD_C;_CRT_RAND_S;_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE;_ATL_NO_OPENGL;_WINDOWS;CERT_CHAIN_PARA_HAS_EXTRA_FIELDS;PSAPI_VERSION=2;WIN32;_SECURE_ATL;WINUWP;WRL_NO_DEFAULT_LIB;WINAPI_FAMILY=WINAPI_FAMILY_PC_APP;WIN10=_WIN32_WINNT_WIN10;WIN32_LEAN_AND_MEAN;NOMINMAX;_UNICODE;UNICODE;NTDDI_VERSION=NTDDI_WIN10_RS2;_WIN32_WINNT=0x0A00;WINVER=0x0A00;NDEBUG;NVALGRIND;DYNAMIC_ANNOTATIONS_ENABLED=0;WEBRTC_ENABLE_PROTOBUF=0;WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE;RTC_ENABLE_VP9;HAVE_SCTP;WEBRTC_LIBRARY_IMPL;WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0;WEBRTC_WIN;ABSL_ALLOCATOR_NOTHROW=1;HAVE_SCTP;WEBRTC_VIDEO_CAPTURE_WINRT

posted on 2023-02-07 15:15  WillingCPP  阅读(350)  评论(0编辑  收藏  举报

导航