# 1、设置 bash
~$ export http_porxy="http://127.0.0.1:1080" # 不支持socks5,也不支持tsock
~$ export https_porxy="https://127.0.0.1:1080"
# 2、设置 git
~$ git config --golab http.proxy="http://127.0.0.1:1080"
~$ git config --golab https.proxy="https://127.0.0.1:1080"
# 3、设置gclient
~$ echo 'export http_porxy="http://127.0.0.1:1080"' >> ~/.boto
~$ echo 'export https_porxy=$http_porxy' >> ~/.boto
~$ export NO_AUTH_BOTO_CONFIG=~/.boto
depot_tools
并添加工具到当前环境变量~$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
~$ export PATH="$PATH:/path/to/depot_tools"
WebRTC
源码~$ mkdir ~/webrtc
~$ cd ~/webrtc
~$ fetch --nohooks webrtc_android
fetch
完成后会自动执行gclient sync
命令,中途下载失败或中断可继续执行gclient sync
同步代码。其中webrtc_android
是指android平台,这一步也可以选择其他平台如chromium
、webrtc_ios
。
下载后若要增加其他平台可选择如下操作,或者手动在../.gclient
文件中添加 'linux'
到已有的target_os
配置项 (建议使用手动添加的方式)
~$ echo "target_os = [ 'linux' ]" >> ../.gclient
我这里需要编译 arm64
的 linux
版本,我的配置文件内容如下:
solutions = [
{
"name": "src",
"url": "https://webrtc.googlesource.com/src.git",
"deps_file": "DEPS",
"managed": False,
"custom_deps": {},
},
]
target_os = ["android", "unix", "linux"]
配置完成后执行:
~$ gclient sync
此步骤无需
~$ cd ~/webrtc/src/
~$ ./build/install-build-deps-android.sh
~$ source ./build/android/envsetup.sh # 刷新编译环境
编译aarch64
平台的朋友直接使用arm64
参数就可以,arm64
为Apple创建,aarch64
由GNU/GCC创建,现在两个平台已合并,略有区别,但两个名称都是同一个东西,
参考:
本项下载需要,这里如果使用socks5
代理协议的话,需要安装tsocks
,build/linux/sysroot_scripts/install-sysroot.py
程序中使用的urlopen
库与 wget
类似,不支持socks5
需要手动安装 tsocks
并手动配置 /etc/tsocks.conf
文件。
这里使用tsocks
可以成功下载根文件系统,但我在执行tsocks gclient sync
时tsocks
始终是不生效,还是建议准备一个http
协议的代理
使用socks5
代理协议
~$ sudo apt-get install tsocks # 配置过程略
~$ cd ~/webrtc/src/
~$ tsocks ./build/linux/sysroot_scripts/install-sysroot.py --arch=arm64
使用http(s)
代理协议
~$ cd ~/webrtc/src/
~$ ./build/linux/sysroot_scripts/install-sysroot.py --arch=arm64
~$ gn gen out/Debug-Linux-arm64 --args='target_os="linux" target_cpu="arm64"'
GN构建配置 - 官方介绍
~$ ninja -C out/Debug-Linux-arm64
3.1、‘XXX/XXX/XXX.h’ file not found
只需要找到对应头文件,添加到对应编译输出目录的*.ninja
文件中就可以
如:
~$ ninja -C out/Debug-Linux-arm64
ninja: Entering directory `out/Debug-Linux-arm64'
[45/3769] CXX obj/modules/desktop_capture/desktop_capture_generic/base_capturer_pipewire.o
FAILED: obj/modules/desktop_capture/desktop_capture_generic/base_capturer_pipewire.o
../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/modules/desktop_capture/desktop_capture_generic/base_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=\"n356902-4e813bbd-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 -D_LIBCPP_DEBUG=0 -DCR_LIBCXX_REVISION=375504 -DCR_SYSROOT_HASH=96072272c5c3dc906fdce0517368b8a298af7abd -D_DEBUG -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DWEBRTC_ENABLE_PROTOBUF=1 -DWEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE -DRTC_ENABLE_VP9 -DHAVE_SCTP -DWEBRTC_ARCH_ARM64 -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 -DWEBRTC_USE_X11 -I../.. -Igen -I../../third_party/abseil-cpp -I../../third_party/libyuv/include -I/workspace/libs/webRTC/webrtc/src/build/linux/debian_sid_arm64-sysroot/usr/include/glib-2.0/ -I/workspace/libs/webRTC/webrtc/src/build/linux/debian_sid_arm64-sysroot/usr/lib/aarch64-linux-gnu/glib-2.0/include/ -I/workspace/libs/webRTC/webrtc/src/build/linux/debian_sid_arm64-sysroot/usr/include/gio-unix-2.0/gio -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=aarch64-linux-gnu -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -Xclang -fdebug-compilation-dir -Xclang . -no-canonical-prefixes -Wall -Werror -Wextra -Wimplicit-fallthrough -Wunreachable-code -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-final-dtor-non-final-class -Wno-builtin-assume-aligned-alignment -Wno-deprecated-copy -Wno-non-c-typedef-for-linkage -Wno-max-tokens -O0 -fno-omit-frame-pointer -g2 -Xclang -debug-info-kind=constructor -gsplit-dwarf -ggnu-pubnames -ftrivial-auto-var-init=pattern -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wexit-time-destructors -Wglobal-constructors -Wc++11-narrowing -Wimplicit-fallthrough -Wthread-safety -Winconsistent-missing-override -Wundef -Wunused-lambda-capture -Wno-shorten-64-to-32 -isystem../../build/linux/debian_sid_arm64-sysroot/opt/zlg/m1808-sdk-1.0-ga/host/aarch64-buildroot-linux-gnu/sysroot/usr/include -isystem../../build/linux/debian_sid_arm64-sysroot/opt/zlg/m1808-sdk-1.0-ga/host/aarch64-buildroot-linux-gnu/sysroot/usr/include/glib-2.0 -isystem../../build/linux/debian_sid_arm64-sysroot/opt/zlg/m1808-sdk-1.0-ga/host/aarch64-buildroot-linux-gnu/sysroot/usr/lib/aarch64-linux-gnu/glib-2.0/include -isystem../../build/linux/debian_sid_arm64-sysroot/opt/zlg/m1808-sdk-1.0-ga/host/aarch64-buildroot-linux-gnu/sysroot/usr/include/libmount -isystem../../build/linux/debian_sid_arm64-sysroot/opt/zlg/m1808-sdk-1.0-ga/host/aarch64-buildroot-linux-gnu/sysroot/usr/include/blkid -isystem../../build/linux/debian_sid_arm64-sysroot/opt/zlg/m1808-sdk-1.0-ga/host/aarch64-buildroot-linux-gnu/sysroot/usr/include/gio-unix-2.0 -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare -std=c++14 -fno-trigraphs -Wno-trigraphs -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_arm64-sysroot -fvisibility-inlines-hidden -Wnon-virtual-dtor -Woverloaded-virtual -c ../../modules/desktop_capture/linux/base_capturer_pipewire.cc -o obj/modules/desktop_capture/desktop_capture_generic/base_capturer_pipewire.o
../../modules/desktop_capture/linux/base_capturer_pipewire.cc:13:10: fatal error: 'gio/gunixfdlist.h' file not found
#include
^~~~~~~~~~~~~~~~~~~
1 error generated.
[54/3769] CXX obj/modules/video_coding/codecs/av1/libaom_av1_encoder/libaom_av1_encoder.o
ninja: build stopped: subcommand failed.
1、找到gunixfdlist.h
文件
~$ find ./ -name "gunixfdlist.h"
./build/linux/debian_sid_i386-sysroot/usr/include/gio-unix-2.0/gio/gunixfdlist.h
./build/linux/debian_sid_arm64-sysroot/usr/include/gio-unix-2.0/gio/gunixfdlist.h
./build/linux/debian_sid_amd64-sysroot/usr/include/gio-unix-2.0/gio/gunixfdlist.h
2、我们编译的arm64平台,所以选择第二条,构造得到绝对路径如下
${WebRTC_SRC_PATH}/build/linux/debian_sid_arm64-sysroot/usr/include/gio-unix-2.0/
3、将构造的到的路径,写到${WebRTC_SRC_PATH}/out/Debug-Linux-arm64/obj/modules/desktop_capture/desktop_capture_generic.ninja
文件的 include_dirs
配置项。如下:
include_dirs = -I../.. -Igen -I../../third_party/abseil-cpp -I../../third_party/libyuv/include -I${WebRTC_SRC_PATH}/build/linux/debian_sid_arm64-sysroot/usr/include/glib-2.0/ -I${WebRTC_SRC_PATH}/build/linux/debian_sid_arm64-sysroot/usr/lib/aarch64-linux-gnu/glib-2.0/include/ -I${WebRTC_SRC_PATH}/build/linux/debian_sid_arm64-sysroot/usr/include/gio-unix-2.0/
4、重新执行编译
~$ ninja -C out/Debug-Linux-arm64
3.2、特别说明:以下头文件目录选用不对会导致编译失败
gtk.h
有3.0
和4.0
两个版本,选用3.0版本vulkan.h
从文件路径上不能明确区分arm64平台版本,需要选用 {$WebRTC_SRC_PATH}/third_party/vulkan_headers/include/