用于 arm 的 WebRTC 构建 [英] WebRTC building for arm

查看:20
本文介绍了用于 arm 的 WebRTC 构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用 arm926ej-s 处理器为我的小型机器构建 webrtc.
安装 depot_tools 后,我执行了以下步骤:

I want to build webrtc for my small machine with arm926ej-s processor.
After I install depot_tools, I did following steps:

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

一切正常,我可以运行一些编译后得到的二进制文件.
现在,我想为我的 arm 机器编译.我执行以下操作:

All working fine and I can run some binary files, which I get after compiling.
Now, I want to compile for my arm machine. I do following:

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 

还是很顺利...
但是当我尝试使用命令编译它时:

Still all smoothly...
But when I try to compile it with command:

ninja -C out/Debug

我遇到了很多错误,例如:

I got many errors, like:

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 识别.

i also got this problem but it was because of the exports related to compiler choices (CC, CXX, etc.). Indeed this makes you faulty since -Xclang is not recognized by gcc.

这是我用来尝试编译的一种方法.但是,似乎 webrtc 主干正在快速移动,并且最近几天不再工作.与您的问题和 9dan 的建议相关的最大变化:您需要说明您想要针对 android(和 linux),为此您需要 android_tools.但是现在,它不是从 webrtc 获取的,你应该从 Chromium 获取.

Here is a method i used to try to compile. However, it seems that webrtc trunk is moving fast and it is no more working these last days. The biggest change that is related to your problem and the suggestion of 9dan : you need to say that you want to target android (and linux) and for this you need android_tools. But now, it is not fetched from webrtc, you should get the one from chromium.

这里是安装过程的摘要.

Here is a summary of the install process.

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

Prefer a virtualized Lubuntu14.04 64bit on at least 30Gb virtual drive space and 8GbRAM :

_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

然后,从这个主机,这里是安装过程:

Then, from this host, here is the install process:

首先安装必要的包,以便能够获取数据并使用 java :

First install the essential packages to be able to fetch data and play with 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 获取

创建一个目录来获取和去

initial Webrtc fetch

Create a directory to fetch and go

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 等.这通常发生在缺少大量软件包的全新安装中.幸运的是,应该已经下载了一个脚本:

Note 0: sometime it fails saying gcc, pkg-config, etc have not been found. This often occurs on a fresh install where plenty of packages are missing. Fortunately a script should have already been downloaded :

trunk/built/install-build-deps.sh 

运行它以安装所有必需的包并重新运行

Run it to install all required packages and rerun

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:android 工具不再直接与 webrtc 一起使用.建议使用铬中的一种.然后,在 Webrtc 文件夹或另一个文件夹中(例如,原始位置:trunk/third_party/).

Note 1: the android tools are no more directly available with webrtc. It is recommended to use the one from chromium. then, in Webrtc folder or another one (example, the original location : trunk/third_party/).

cd myTargetDirectory // example cd trunk/third_party/
git clone https://chromium.googlesource.com/android_tools

获取 android_tools 后,配置项目以查看它.

Once android_tools are fetched, configure project to see it. Edit :

trunk/chromium/src/third_party/openmax_dl/dl/dl.gyp

并通过在文件开头的变量"部分添加以下行来添加所需的变量 android_ndk_root:

and add the required variable android_ndk_root by adding the following line in the 'variables' section at the beginning of the file:

'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

you can also export ANDROID_NDK_ROOT in your .bashrc

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)*/

/* => after different experiment, i used the above command, but i guess it is not absolutely necessary from a very clean install. Anycase, if done, command "./build/install-build-deps.sh --arm" should be used after in order to exchange some cross compiler packages (mainly in order to keep g++-arm-linux-gnueabihf and gcc-arm-linux-gnueabihf installed) */

./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,可能需要定义以下变量

Here, the target is linux arm so this should be enough but if targetting android, it may be necessary to define the following variables

export ANDROID_SDK_VERSION=19
export GYP_DEFINES="$GYP_DEFINES  android_sdk_version=19"

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

NOTE 2 : the following exports are often reported on guides and tutorials. However, when used, they bring several problems (unrecognized -Xclang flag, etc.). It seems that they are no more usefull since gyp files automatically adjust those setup ! For me, avoiding them was the only way to get configuration and beginning of compilation work.

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++

最后,在进入最后的编译步骤之前配置系统

Finally, configure the system before moving to the final compile step

cd ..
gclient runhooks --force
 cd trunk/

潜在错误1,已解决

首先出现以下错误:=> gyp:chromium/src/third_party/openmax_dl/dl/dl.gyp 中未定义的变量 android_ndk_root=> 回到上一节,你肯定忘了在 enlighted 文件中定义 android_ndk_root 变量:'android_ndk_root':'/trunk/third_party/android_tools/ndk/',*/

Potential error 1 , Solved

The following error appears first : => gyp: Undefined variable android_ndk_root in chromium/src/third_party/openmax_dl/dl/dl.gyp => come back to previous section, you certainly forgot to define android_ndk_root variable in the enlighted file: 'android_ndk_root':'/trunk/third_party/android_tools/ndk/', */

尝试定位trunk/build/linux/pkg-config-wrapper时出现相对链接问题,你可以得到类似的东西:正在从 gyp 文件更新项目.../bin/sh: ../../../build/linux/pkg-config-wrapper: 没有那个文件或目录gyp:调用 '../../../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=> 如果您想为所有有此错误的文件解决此问题,请使用以下命令查找错误文件:

a relative link problem appears when trying to target trunk/build/linux/pkg-config-wrapper, you can get something similar to this : Updating projects from gyp files... /bin/sh: ../../../build/linux/pkg-config-wrapper: No such file or directory gyp: Call to '../../../build/linux/pkg-config-wrapper "/media/workspace/lib/webrtc/trunk/arm-sysroot" "arm" --libs-only-L --libs-only-other nss' returned exit status 127. while loading dependencies of trunk/all.gyp while trying to load trunk/all.gyp Error: Command /usr/bin/python trunk/build/gyp_chromium --depth=trunk trunk/all.gyp -Dextra_gyp_flag=0 returned non-zero exit status 1 in /media/workspace/lib/webrtc => if you want to solve this problem for all files having this error, look for wrong files with :

grep -Ir --exclude=\*.{c,h} "../../../build/linux/pkg-config-wrapper" *

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

and replace related relative path portion in pkg config line (at the beginning of each of the found files : 'pkg-config': 'trunk/build/linux/pkg-config-wrapper "<(sysroot)" "<(target_arch)"',

gclient 运行挂钩 --force

gclient runhooks --force

cd trunk
ninja -C out/Release/
ninja -C out/Debug/ // if required

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

an idea : sudo apt-get install gcc-arm-linux-androideabi you should target third_party/android_tools/ndk/platforms/android-XXX/arch-arm/usr/include/sys/

//如果 clang 有问题,可以使用此附加选项将其停用(之后重新运行 gclien runhooks)

// if having problems with clang, it can be desactivated with this additionnal option (rerun gclien runhooks after)

export GYP_DEFINES="$GYP_DEFINES clang=0"

这篇关于用于 arm 的 WebRTC 构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆