linux - WebRTC构建 ARM

标签 linux build arm webrtc

我想用arm926ej-s处理器为我的小型机器构建webrtc。

安装depot_tools之后,请执行以下步骤:

gclient config http://webrtc.googlecode.com/svn/trunk
gclient sync --force
cd trunk
ninja -C out/Debug

一切正常,我可以运行一些二进制文件,这些文件在编译后即可获得。
现在,我想为我的 ARM 机器编译。我做以下事情:
rm -rf out
export GYP_CROSSCOMPILE=1
export GYP_DEFINES="target_arch=arm arm_float_abi=hard"
export CC=/path/to/my/gcc
export CXX=/path/to/my/g++
export AR=/path/to/my/ar
export CC_host=gcc 
export CXX_host=g++ 
gclient runhooks --force 

仍然一切顺利...
但是当我尝试使用命令编译它时:
ninja -C out/Debug

我遇到很多错误,例如:
CC obj/chromium/src/third_par...p/srtp/crypto/cipher/libsrtp.aes_cbc.o
FAILED: /opt/virt2real-sdk/codesourcery/arm-2013.05/bin/arm-none-linux-gnueabi-gcc -MMD -MF obj/chromium/src/third_party/libsrtp/srtp/crypto/cipher/libsrtp.aes_cbc.o.d -DHAVE_STDLIB_H -DHAVE_STRING_H -DV8_DEPRECATION_WARNINGS -D_FILE_OFFSET_BITS=64 -DHAVE_INT16_T -DHAVE_INT32_T -DHAVE_INT8_T -DHAVE_UINT16_T -DHAVE_UINT32_T -DHAVE_UINT64_T -DHAVE_UINT8_T -DHAVE_STDINT_H -DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H -DINLINE=inline -DCPU_CISC -DCHROMIUM_BUILD -DCR_CLANG_REVISION=214024 -DTOOLKIT_VIEWS=1 -DUI_COMPOSITOR_IMAGE_TRANSPORT -DUSE_AURA=1 -DUSE_ASH=1 -DUSE_PANGO=1 -DUSE_CAIRO=1 -DUSE_GLIB=1 -DUSE_DEFAULT_RENDER_THEME=1 -DUSE_LIBJPEG_TURBO=1 -DUSE_X11=1 -DUSE_CLIPBOARD_AURAX11=1 -DENABLE_ONE_CLICK_SIGNIN -DENABLE_PRE_SYNC_BACKUP -DUSE_XI2_MT=2 -DENABLE_REMOTING=1 -DENABLE_WEBRTC=1 -DENABLE_PEPPER_CDMS -DENABLE_CONFIGURATION_POLICY -DENABLE_NOTIFICATIONS -DUSE_UDEV -DENABLE_EGLIMAGE=1 -DENABLE_TASK_MANAGER=1 -DENABLE_EXTENSIONS=1 -DENABLE_PLUGINS=1 -DENABLE_SESSION_SERVICE=1 -DENABLE_THEMES=1 -DENABLE_AUTOFILL_DIALOG=1 -DENABLE_BACKGROUND=1 -DENABLE_GOOGLE_NOW=1 -DCLD_VERSION=2 -DCLD2_DATA_SOURCE=static -DENABLE_FULL_PRINTING=1 -DENABLE_PRINTING=1 -DENABLE_SPELLCHECK=1 -DENABLE_CAPTIVE_PORTAL_DETECTION=1 -DENABLE_APP_LIST=1 -DENABLE_SETTINGS_APP=1 -DENABLE_MANAGED_USERS=1 -DENABLE_MDNS=1 -DENABLE_SERVICE_DISCOVERY=1 -DUSE_NSS=1 -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DWTF_USE_DYNAMIC_ANNOTATIONS=1 -D_DEBUG -D_GLIBCXX_DEBUG=1 -I../../chromium/src/third_party/libsrtp/config -I../../chromium/src/third_party/libsrtp/srtp/include -I../../chromium/src/third_party/libsrtp/srtp/crypto/include -Igen -fstack-protector --param=ssp-buffer-size=4 -Werror -pthread -fno-exceptions -fno-strict-aliasing -Wno-unused-parameter -Wno-missing-field-initializers -fvisibility=hidden -pipe -fPIC -Wno-reserved-user-defined-literal -Xclang -load -Xclang /home/footniko/my/webrtcnative/trunk/tools/clang/scripts/../../../third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.so -Xclang -add-plugin -Xclang find-bad-constructs -fcolor-diagnostics -Wheader-hygiene -Wno-char-subscripts -Wno-unneeded-internal-declaration -Wno-covered-switch-default -Wstring-conversion -Wno-c++11-narrowing -Wno-deprecated-register -Wno-format -Wno-unused-result -target arm-linux-gnueabihf -march=armv7-a -no-integrated-as -mtune=generic-armv7-a -mfpu=neon -mfloat-abi=hard -mthumb --sysroot=/home/footniko/my/webrtcnative/trunk/arm-sysroot -O0 -g -funwind-tables -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare   -c ../../chromium/src/third_party/libsrtp/srtp/crypto/cipher/aes_cbc.c -o obj/chromium/src/third_party/libsrtp/srtp/crypto/cipher/libsrtp.aes_cbc.o
arm-none-linux-gnueabi-gcc: error: unrecognized command line option '-Xclang'
arm-none-linux-gnueabi-gcc: error: unrecognized command line option '-Xclang'
arm-none-linux-gnueabi-gcc: error: unrecognized command line option '-Xclang'
arm-none-linux-gnueabi-gcc: error: unrecognized command line option '-add-plugin'
arm-none-linux-gnueabi-gcc: error: unrecognized command line option '-Xclang'
arm-none-linux-gnueabi-gcc: error: find-bad-constructs: No such file or directory
arm-none-linux-gnueabi-gcc: error: unrecognized command line option '-fcolor-diagnostics'
arm-none-linux-gnueabi-gcc: error: unrecognized command line option '-Wheader-hygiene'
arm-none-linux-gnueabi-gcc: error: unrecognized command line option '-Wstring-conversion'
arm-none-linux-gnueabi-gcc: error: unrecognized command line option '-target'
arm-none-linux-gnueabi-gcc: error: arm-linux-gnueabihf: No such file or directory
arm-none-linux-gnueabi-gcc: error: unrecognized command line option '-no-integrated-as'

最佳答案

我也遇到了这个问题,但这是因为与编译器选择(CC,CXX等)相关的导出。确实,这使您很麻烦,因为-xclang无法被gcc识别。

这是我用来尝试编译的方法。但是,似乎webrtc中继运行很快,并且最近几天不再工作。与您的问题和9dan的建议有关的最大变化是:您需要说的是要以android(和linux)为目标,为此,您需要android_tools。但是现在,它不是从webrtc中获取的,您应该从Chrome中获取它。

这是安装过程的摘要。

系统要求:

在至少30Gb虚拟驱动器空间和8GbRAM上首选64位虚拟化Lubuntu14.04:

_Lubuntu is fast to use when virtualized and it is based on ubuntu which is necessary since installation scripts rely on ubuntu software packages names
_64bit is necessary since scripts like install-build-deps.sh expect 64bit system and install specific 32bit libraries
_30Gb at least because standard (non cross compiling) webrtc requires at least 10Gb but when adding all cross compiling stuff, drive space explodes !
_8GbRAM to be able to compile and link everything

然后,从该主机开始,这是安装过程:

基本的初步设置...假设没有导出稍后讨论的变量

首先安装基本软件包,以便能够获取数据并使用java进行播放:
// ensure all required depot are ready
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe restricted multiverse"
// install most essential packages prior to fetching
sudo apt-get install openjdk-7-jdk git subversion

初始Webrtc提取

创建一个目录以获取并转到
mkdir WebRTC
cd WebRTC
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=<location of depot_tools>:"$PATH" // example : export PATH=/home/testing/WebRTC/depot_tools:"$PATH"
export JAVA_HOME=<location of Java SE 6 - JDK>  // example : export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
gclient config http://webrtc.googlecode.com/svn/trunk 
gclient sync --force

注意0:有时会失败,提示未找到gcc,pkg-config等。这通常发生在缺少大量软件包的全新安装中。
幸运的是,脚本应该已经下载:
trunk/built/install-build-deps.sh 

运行它以安装所有必需的软件包并重新运行
gclient sync --force

添加目标 ARM 系统所需的所有必要android sdk&ndk
echo "target_os = ['android', 'unix']" >> .gclient
gclient sync
cd trunk
source ./build/android/envsetup.sh
export GYP_DEFINES="$GYP_DEFINES OS=android"
gclient runhooks

注意1:Androidrt不再直接提供android工具。建议使用 Chrome 。
然后,在Webrtc文件夹或另一个文件夹中(例如,原始位置:trunk/third_party/)。
cd myTargetDirectory // example cd trunk/third_party/
git clone https://chromium.googlesource.com/android_tools

提取android_tools后,配置项目以查看它。编辑:
trunk/chromium/src/third_party/openmax_dl/dl/dl.gyp

并通过在文件开头的“变量”部分添加以下行来添加所需的变量android_ndk_root:
'android_ndk_root':'<WebRTCfolder>/trunk/third_party/android_tools/ndk/',
example   'android_ndk_root':'/home/testing/WebRTC/trunk/third_party/android_tools/ndk/',

您也可以在.bashrc中导出ANDROID_NDK_ROOT
export ANDROID_NDK_ROOT=<WebRTCfolder>/trunk/third_party/android_tools/ndk/
example export ANDROID_NDK_ROOT=/home/testing/WebRTC/trunk/third_party/android_tools/ndk/

为基于armv7a的平台准备交叉编译
// install all necessary packages
cd trunk
./build/install-build-deps.sh --arm
./build/install-build-deps-android.sh

/* =>经过不同的实验后,我使用了上面的命令,但是我想从一个非常干净的安装中并不是绝对必要的。在任何情况下,如果完成,都应在之后使用命令“./build/install-build-deps.sh --arm”以交换一些交叉编译器软件包
(主要是为了保持安装g++-arm-linux-gnueabihf和gcc-arm-linux-gnueabihf)
*/
./build/linux/install-arm-sysroot.py
export GYP_CROSSCOMPILE=1 /* => i used it but i ask myself if it is still necessary since an automatic declaration is performed later on.*/

export GYP_DEFINES="OS=linux target_arch=arm arm_version=7 arm_use_neon=1"
// other options like  arm_fpu=vfpv3-d16 arm_float_abi=softfp are set by default, actually, even arm_vervion=7 and use_neon=1 */

在这里,目标是linux arm,所以这应该足够了,但是如果以android为目标,则可能有必要定义以下变量
export ANDROID_SDK_VERSION=19
export GYP_DEFINES="$GYP_DEFINES  android_sdk_version=19"

注意2:以下导出经常在指南和教程中报告。但是,使用它们时会带来一些问题(无法识别的-Xclang标志等)。似乎它们不再有用,因为gyp文件会自动调整这些设置!对我来说,避免它们是获得配置和开始编译工作的唯一方法。
export CC=arm-linux-gnueabihf-gcc
export CXX=arm-linux-gnueabihf-g++
export AR=arm-linux-gnueabihf-ar
export CC_host=gcc
export CXX_host=g++

最后,配置系统,然后再进行最后的编译步骤
cd ..
gclient runhooks --force
 cd trunk/

潜在错误1,已解决

首先出现以下错误:
=> gyp: Chrome /src/third_party/openmax_dl/dl/dl.gyp中的 undefined variable android_ndk_root
=>返回上一节,您当然忘记了在启蒙文件中定义android_ndk_root变量:
'android_ndk_root':'/trunk/third_party/android_tools/ndk/',
*/

潜在错误2,已解决

尝试定位trunk/build/linux/pkg-config-wrapper时,出现一个相对链接问题,您可以得到类似以下内容:
正在从gyp文件更新项目...
/bin/sh:../../../build/linux/pkg-config-wrapper:没有这样的文件或目录
gyp: call '../../../build/linux/pkg-config-wrapper“/media/workspace/lib/webrtc/trunk/arm-sysroot”“arm” --libs-only-L- -libs-only-other nss的退出状态为127。在加载trunk/all.gyp的依赖项时,尝试加载trunk/all.gyp
错误:命令/usr/bin/python trunk/build/gyp_chromium --depth = trunk trunk/all.gyp -Dextra_gyp_flag = 0在/media/workspace/lib/webrtc中返回了非零退出状态1
=>如果要解决所有出现此错误的文件的问题,请使用以下命令查找错误的文件:
grep -Ir --exclude=\*.{c,h} "../../../build/linux/pkg-config-wrapper" *

并在pkg config行中替换相关的相对路径部分(在每个找到的文件的开头:
'pkg-config':'trunk/build/linux/pkg-config-wrapper“<(sysroot)”“<(target_arch)”',

gclient runhooks --force

最后的编译步骤
cd trunk
ninja -C out/Release/
ninja -C out/Debug/ // if required

一个想法:sudo apt-get install gcc-arm-linux-androideabi
您应该定位third_party/android_tools/ndk/platforms/android-XXX/arch-arm/usr/include/sys/

//如果clang出现问题,可以使用此附加选项将其停用(此后重新运行gclien runhooks)
export GYP_DEFINES="$GYP_DEFINES clang=0"

关于linux - WebRTC构建 ARM ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25764171/

相关文章:

ruby - 使用 RVM 安装 Ruby 版本时的配置问题

c - arm多少字节对齐?

android - 构建android源代码(AOSP)问题

java - 无法 Maven 构建 "strings in switch are not supported in -source 1.5 in eclipse while maven build"

c++ - 类方法的多重定义

linux - 为 arm-gcc-compiler 安装库

c - strptime() 在 armv7l 环境中产生错误结果

python - Cron 作业语法

linux - 在 info bash 中找不到 'date' 命令的描述 - 找到可从 shell 调用的所有命令的列表

c++ - CMake 中的 OpenCV 和 Gtest 冲突