webrtc 交叉编译

补充说明

开发过程中,发现声网提供了国内镜像,请参考:https://webrtc.org.cn/mirror/。
以下描述,还是按照科学上网、从谷歌下载进行记录。


编译环境

  1. Ubuntu 18.04.3 LTS。
  2. 部分源码、工具,在googlesource(例如webrtcdepot_tools),要求环境可以科学上网
  3. 需要安装git,若未安装,可以参考指令进行安装。 sudo apt-get install git
  4. 需要安装ninja,若未安装,可以参考指令进行安装。 sudo apt-get install ninja-build
  5. 需要安装python 2.7,若未安装,可以参考指令进行安装。 sudo apt-get install python

可能还依赖其他工具、软件,凭记忆无法完全列出。若未列出,请使用apt-get安装所缺少的软件,或者搜索相关安装方法。


安装depot tools

需要科学上网环境,已上传一个到csdn,2019-09版本,可以参考,下载。从网上下载方法如下:

  1. 下载depot tools:
    在目标目录执行如下指令,指令会自动创建depot_tools目录,例如在/home/user/work目录执行:
    git clone https://source.codeaurora.org/quic/lc/chromium/tools/depot_tools
    会创建/home/user/work/depot_tools目录,并且将depot_tools的源码克隆到该目录。

  2. 设置环境变量:
    下载完成后,将depot_tools目录添加到PATH环境变量,因为后续会调用该目录下的fetch等脚本或指令:

    cd depot_tools目录
    export PATH=`pwd`:"$PATH"
    

下载webrtc源码

  1. 创建目录:

    mkdir webrtc
    cd webrtc
    
  2. 下载源码,需要可以科学上网环境:

    export GYP_DEFINES="OS=linux"
    fetch --nohooks webrtc
    gclient sync
    

    如果提示tools和third_party无法下载,可能是网速太慢导致异常,可以修改git1参数下载速率、下载超时配置:

    git config --global http.lowSpeedLimit 0
    git config --global http.lowSpeedTime 9999999
    

    可以尝试用fetch --nohooks webrtc_android,下载完整的webrtc确实非常大,大概17GB。
    gclient sync可以重复执行,如果之前已经下载OK的,不会重复下载,只会下载还未完成的。

  3. 源码下载完成后,安装相关依赖,假设当前在webrtc目录:
    Ubuntu可以先将软件更新源设置为清华镜像,速度会快很多。

    cd src
    ./build/install-build-deps.sh --arm
    ./build/linux/sysroot_scripts/install-sysroot.py --arch=arm
    

    执行以上指令时,如果出现下载chrome fonts超时,请在指令后添加–no-chromeos-fonts:
    ./build/install-build-deps.sh --arm --no-chromeos-fonts


进行编译

编译arm linux版本,install-build-deps.sh自动安装arm-linux-gnueabihf-gcc,支持信息如下:

Using built-in specs.
COLLECT_GCC=arm-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/arm-linux-gnueabihf/7/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --enable-multilib --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueabihf --program-prefix=arm-linux-gnueabihf- --includedir=/usr/arm-linux-gnueabihf/include
Thread model: posix
gcc version 7.4.0 (Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1) 
  1. 使用 gn 生成 ninja 构建文件:gn gen out/Default --args='target_os="linux" target_cpu="arm"'
  2. 使用ninja编译webrtc:ninja -C out/Default

编译过程中只遇到一个类型的错误(反复出现几次),修改后顺利完成编译。在目标单板上可以运行部分程序(有些依赖libX11.so库,后续需要去掉,另外编译默认是硬浮点,估计后续也需要修改)。

编译完的结果,在webrtc/src/out/Default目录,挂载到目标板可以执行,尚未配置运行环境,随意执行了2个可执行文件大致如下:
在这里插入图片描述


遇到错误

错误1:

../../build/linux/debian_sid_arm-sysroot/usr/include/glib-2.0/glib/gtypes.h:32:10: fatal error: 'glibconfig.h' file not found

解决办法:
找到对应的ninja文件,增加如下头文件目录包含。具体目录,可以查找glibconfig.h,包含所在目录:

../../build/linux/debian_sid_arm-sysroot/usr/include/glib-2.0/glib/gtypes.h:32:10: fatal error: 'glibconfig.h' file not found

例如:

ninja: Entering directory `out/Default'
[1/1683] CXX obj/modules/desktop_capture/desktop_capture_generic/screen_capturer_pipewire.o
FAILED: obj/modules/desktop_capture/desktop_capture_generic/screen_capturer_pipewire.o 
../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/modules/desktop_capture/desktop_capture_generic/screen_capturer_pipewire.o.d -DUSE_UDEV -DUSE_AURA=1 -DUSE_GLIB=1 -DUSE_NSS_CERTS=1 -DUSE_X11=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -DCR_CLANG_REVISION=\"370156-69640273-1\" -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_LIBCPP_ABI_UNSTABLE -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_ENABLE_NODISCARD -DCR_LIBCXX_REVISION=361348 -DCR_SYSROOT_HASH=ef5c4f84bcafb7a3796d36bb1db7826317dde51c -D_DEBUG -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DWEBRTC_ENABLE_PROTOBUF=1 -DWEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE -DRTC_ENABLE_VP9 -DHAVE_SCTP -DWEBRTC_ARCH_ARM -DWEBRTC_ARCH_ARM_V7 -DWEBRTC_HAS_NEON -DWEBRTC_USE_PIPEWIRE -DWEBRTC_DLOPEN_PIPEWIRE -DWEBRTC_LIBRARY_IMPL -DWEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=1 -DWEBRTC_POSIX -DWEBRTC_LINUX -DABSL_ALLOCATOR_NOTHROW=1 -I../.. -Igen -I../../third_party/abseil-cpp -I../../third_party/libyuv/include -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -funwind-tables -fPIC -pthread -fcolor-diagnostics -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -Xclang -mllvm -Xclang -instcombine-lower-dbg-declare=0 -fcomplete-member-pointers --target=arm-linux-gnueabihf -march=armv7-a -mfloat-abi=hard -mtune=generic-armv7-a -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -Xclang -fdebug-compilation-dir -Xclang . -no-canonical-prefixes -mfpu=neon -mthumb -Wall -Werror -Wextra -Wimplicit-fallthrough -Wthread-safety -Wextra-semi -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-unneeded-internal-declaration -Wno-undefined-var-template -Wno-ignored-pragma-optimize -Wno-implicit-int-float-conversion -Wno-xor-used-as-pow -O0 -fno-omit-frame-pointer -g2 -gsplit-dwarf -ggnu-pubnames -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wexit-time-destructors -Wglobal-constructors -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wc++11-narrowing -Wimplicit-fallthrough -Wthread-safety -Winconsistent-missing-override -Wundef -Wunused-lambda-capture -isystem../../build/linux/debian_sid_arm-sysroot/usr/include/gio-unix-2.0/ -isystem../../build/linux/debian_sid_arm-sysroot/usr/include/glib-2.0 -isystem../../build/linux/debian_sid_arm-sysroot/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare -std=c++11 -fno-exceptions -fno-rtti -nostdinc++ -isystem../../buildtools/third_party/libc++/trunk/include -isystem../../buildtools/third_party/libc++abi/trunk/include --sysroot=../../build/linux/debian_sid_arm-sysroot -fvisibility-inlines-hidden -Wnon-virtual-dtor -Woverloaded-virtual -c ../../modules/desktop_capture/linux/screen_capturer_pipewire.cc -o obj/modules/desktop_capture/desktop_capture_generic/screen_capturer_pipewire.o
In file included from ../../modules/desktop_capture/linux/screen_capturer_pipewire.cc:11:
In file included from ../../modules/desktop_capture/linux/screen_capturer_pipewire.h:16:
In file included from ../../modules/desktop_capture/linux/base_capturer_pipewire.h:14:
In file included from ../../build/linux/debian_sid_arm-sysroot/usr/include/glib-2.0/gio/gio.h:26:
In file included from ../../build/linux/debian_sid_arm-sysroot/usr/include/glib-2.0/gio/giotypes.h:28:
In file included from ../../build/linux/debian_sid_arm-sysroot/usr/include/glib-2.0/gio/gioenums.h:28:
In file included from ../../build/linux/debian_sid_arm-sysroot/usr/include/glib-2.0/glib-object.h:23:
In file included from ../../build/linux/debian_sid_arm-sysroot/usr/include/glib-2.0/gobject/gbinding.h:28:
In file included from ../../build/linux/debian_sid_arm-sysroot/usr/include/glib-2.0/glib.h:30:
In file included from ../../build/linux/debian_sid_arm-sysroot/usr/include/glib-2.0/glib/galloca.h:32:
../../build/linux/debian_sid_arm-sysroot/usr/include/glib-2.0/glib/gtypes.h:32:10: fatal error: 'glibconfig.h' file not found
#include <glibconfig.h>
         ^~~~~~~~~~~~~~
1 error generated.

则修改out/Default/obj/modules/desktop_capture目录下的desktop_capture_generic.ninja文件。


  1. git参数官方说明:http.lowSpeedLimit, http.lowSpeedTime: If the HTTP transfer speed is less than http.lowSpeedLimit for longer than http.lowSpeedTime seconds, the transfer is aborted. Can be overridden by the GIT_HTTP_LOW_SPEED_LIMIT and GIT_HTTP_LOW_SPEED_TIME environment variables. ↩︎

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 10
    评论
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值