Webrtc Building for Arm

WebRTC building for arm

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.

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.

System requirements:

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:

basic preliminary setup... supposing that no variables discussed later have already been exported

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

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

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

add all necessary android sdk&ndk that are required to target arm systems

echo "target_os = ['android', 'unix']" >> .gclient
gclient sync
cd trunk
source ./build/android/envsetup.sh
export GYP_DEFINES="$GYP_DEFINES OS=android"
gclient runhooks

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

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

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

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/',

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/

prepare cross compile for armv7a based platform

// install all necessary packages
cd trunk
./build/install-build-deps.sh --arm
./build/install-build-deps-android.sh

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

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"

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/

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/',
*/

Potential error 2, solved

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" *

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 runhooks --force

final compile step

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

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/

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

export GYP_DEFINES="$GYP_DEFINES clang=0"

failed cross compiling aws webrtc library

Something is wrong with your ARM toolchain or how the build system uses it. Where did you get it from and how did you install it?

The header sys/capability.h is included with the ARM toolchain. For example, when I install the Debian package gcc-arm-linux-gnueabihf then this header file gets copied to /usr/arm-linux-gnueabihf/include/linux/capability.h. The toolchain is supposed to find it there on its own.

The command arm-linux-gnueabihf-gcc -v will show you where the toolchain is configured to look for its own header files. E.g. in output below it's --includedir=/usr/arm-linux-gnueabihf/include that matters, the header should be found relative to this directory. I apologize for the super long line.

$ arm-linux-gnueabihf-gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/arm-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/arm-linux-gnueabihf/10/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Debian 10.2.1-1' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --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 --enable-libphobos-checking=release --without-target-system-zlib --enable-multiarch --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --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 --with-build-config=bootstrap-lto-lean --enable-link-mutex
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.1 20201207 (Debian 10.2.1-1)

You can also try increasing the verbosity of your cmake build process to verify that it's calling the right cross compiler. I've forgotten the details, but perhaps adding a flag -v will help.

library link error when cross-compiling aws webrtc library

I just solved it by using mbedtls instead of OpenSSL. Try it with mbedtls if there is someone who have the same issue.

cmake .. -DBUILD_STATIC_LIBS=TRUE -DUSE_OPENSSL=FALSE -DUSE_MBEDTLS=TRUE -DBUILD_LIBSRTP_HOST_PLATFORM=x86_64-pc-linux-gnu -DBUILD_LIBSRTP_DESTINATION_PLATFORM=arm-linux-gnueabihf

cannot find the nanosleep function when cross compile configure

nanosleep requires _POSIX_C_SOURCE >= 199309L feature macro as specified by man nanosleep.

Try adding #define _POSIX_C_SOURCE 199309L before #include <time.h>.



Related Topics



Leave a reply



Submit