JCHub

  • Home
  • Category
    • A/V
    • WebRTC
    • Beauty of Programming
    • Linux
    • Windows
    • Moments of Life
    • Campus Life
  • Reference
    • API Reference
    • Utilities
    • AV Test
    • Doc
  • Message Board
  • About
JCHub
Code as My Sword, Lost in Obsession
  1. Main page
  2. WebRTC
  3. Main content

Linux平台WebRTC编译

2021年1月28日 4219hotness 13likes 3comments

系统要求

  • 系统:Ubuntu 16.04及以上(本文Ubuntu 18.04)
  • 磁盘空间:至少6.4 GB磁盘空间

安装工具

1
2
sudo apt-get update
sudo apt-get install -y vim git python

安装depot tools

1
2
3
4
5
6
7
cd ~
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
 
vi ~/.bashrc
# .bashrc添加如下一行
export PATH="$PATH:~/depot_tools"
source ~/.bashrc

获取代码

1
2
3
4
mkdir webrtc-checkout
cd webrtc-checkout
fetch --nohooks webrtc
gclient sync

安装依赖

1
2
cd src
./build/install-build-deps.sh

生成Ninja工程文件

WebRTC默认使用Ninja作为编译系统,Ninja工程文件通过GN生成。

使用如下命令生成默认配置工程(Debug编译,工程文件位于out\Default目录下):

1
gn gen out/Default

如果需要Release编译,通过如下命令生成工程文件:

1
gn gen out/Default --args='is_debug=false'

编译

1
ninja -C out/Default

最后在src/out/Default/obj可以看到生成的静态库文件:libwebrtc.a。

代码更新

后续如需要更新代码,按照如下步骤:

1
2
3
git checkout master
git pull origin master
gclient sync

然后参考前面步骤重新生成工程文件,编译即可。

参考

[1] WebRTC Native code Development.https://webrtc.github.io/webrtc-org/native-code/development/.

本文已收录到大话WebRTC专栏,更多精彩请访问《大话WebRTC》。

This article is licensed with Creative Commons Attribution-NonCommercial-No Derivatives 4.0 International License
Tag: WebRTC
Last updated:2021年3月3日

Jeff

管理员——代码为剑,如痴如醉

Tip the author Like
< Last article
Next article >

Comments

  • juanhe

    你好 ,刚接触ubuntu,在编译webrtc中遇到一个问题,执行fetch --nohooks webrtc,报错显示/usr/bin/env: "bash\r": 没有那个文件或目录,百度搜索了一下 ,修改后还是不可行,请问有什么方法解决此问题吗?

    2021年8月4日
    Reply
    • dongl

      @juanhe vim ~/.bashrc

      ## depot_tools
      export PATH=$PATH:/‘pwd’/depot_tools

      pwd 你的depot_tools安装路径

      2023年10月9日
      Reply
  • yezi

    linux下按照这个方法安装后并不能编译通过示例,是不是有什么步骤遗漏了。

    2024年7月25日
    Reply
  • razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
    Cancel

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    文章目录
    • 系统要求
    • 安装工具
    • 安装depot tools
    • 获取代码
    • 安装依赖
    • 生成Ninja工程文件
    • 编译
    • 代码更新
    • 参考
    Related Posts
    • 浅谈基于SFU实现一对一效果
    • WebRTC资讯:H265支持进展
    • Protected: WebRTC硬件编解码器出错无缝切换软编软解
    • WebRTC研究:Audio level
    • Mac平台WebRTC编译
    Categories

    COPYRIGHT © 2026 jianchihu.net. ALL RIGHTS RESERVED.

    Theme Kratos Made By Seaton Jiang