Ubuntu下载编译webrtc源码(需要代理)

 下载webrtc源码需要代理访问外网!

我的方法需要代理,如果没有代理就不要往下看了。

一、安装必备工具和依赖

sudo apt update

sudo apt install -y git python3-pip build-essential pkg-config libssl-dev libglib2.0-dev libpulse-dev libasound2-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxdamage-dev libxfixes-dev libxcomposite-dev libxss-dev libxtst-dev libgtk-3-dev libudev-dev curl


二、获取 depot_tools

WebRTC 使用 Google 的 depot_tools 来管理仓库和编译。

我把depot_tools 放在了桌面(Desktop)上

cd ~/Desktop

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

echo 'export PATH=$PATH:$HOME/Desktop/depot_tools' >> ~/.bashrc

source ~/.bashrc

确认安装成功:

which fetch    # 应该能输出 ~/Desktop/depot_tools/fetch

which gclient   # 应该能输出 ~/Desktop/depot_tools/gclient

三、获取 Webrtc源码

注意:需要代理,要不然无法访问外网

cd ~/Desktop/webrtc-checkout
fetch --nohooks webrtc     # 此处需要代理访问外网,而且要下载很久
gclient sync --with_branch_heads --with_tags

在执行  gclient sync --with_branch_heads --with_tags 可能会报错

zyt@ubuntu:~/Desktop/webrtc-checkout$ gclient sync
depot_tools update failed. Couldn't fetch main branch.Retry later or reclone depot_tools
fatal: 无法访问 'https://chromium.googlesource.com/chromium/tools/depot_tools.git/':gnutls_handshake() failed: The TLS connection was non-properly terminated.

问题是 gclient sync 会自动尝试更新 depot_tools,而更新时又走 HTTPS 导致 TLS 握手失败。解决方法:

在你的 shell 配置里(~/.bashrc 或者当前终端)添加:

export DEPOT_TOOLS_UPDATE=0
export GCLIENT_DISABLE_SELF_UPDATE=1
source ~/.bashrc

这样 gclient 就不会再在每次 sync 前尝试更新 depot_tools。 

看到下面的内容就说明执行成功

Syncing projects: 100% (63/63), done. 
Running hooks: 100% (24/24), done.  

四、开始编译

cd src

gn gen out/Debug_gcc --args='
  is_debug=true
  target_os="linux"
  target_cpu="x64"             
  is_clang=false              
  cc="/usr/bin/gcc-11"         
  cxx="/usr/bin/g++-11"       
'

ninja -C out/Debug_gcc

或者

cd src

# 用 Clang,Debug 模式,不编测试
gn gen out/Debug_clang --args='
  is_debug=true
  target_os="linux"
  target_cpu="x64"
  is_clang=true
'

ninja -C out/Debug_clang

编译完成之后就可以用webrtc源码来开发自己的应用了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值