Skip to content

Build WebRTC Libraries for Raspberry Pi 3 (Cross compile on Ubuntu)

Vahid Daneshmand edited this page Dec 18, 2019 · 14 revisions

Build WebRTC Libraries for Raspberry Pi 3 (Cross compile on Ubuntu 16.04)

Description
Tested on Raspbian Jessie and Stretch on Raspberry Pi 3
Time ~ 60 Minutes
Question(s) - How to build WebRTC for Raspberry Pi 3?
- How to extract WebRTC static libraries for building IPOP?
Objective(s) - Build the WebRTC Libraries
- Extract required WebRTC Static Libraries for Building IPOP

Note 1: If you want to run IPOP right away, use the proper version of IPOP from our latest release.

Note 2: There are some WebRTC libraries needed to build IPOP Tincan binary. They are already built and located in Tincan/external/lib/. You can use them to build IPOP Tincan binary yourself.

If you want to build WebRTC libraries for IPOP yourself, follow the instructions.

Install Toolchain

sudo apt update && sudo apt install -y debootstrap qemu-user-static git python3-dev

mkdir -p ~/workspace/webrtc-checkout && cd ~/workspace/webrtc-checkout/

sudo git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git /opt/depot_tools
echo "export PATH=/opt/depot_tools:\$PATH" | sudo tee /etc/profile.d/depot_tools.sh

sudo git clone https://github.com/raspberrypi/tools.git /opt/rpi_tools
echo "export PATH=/opt/rpi_tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin:\$PATH" | sudo tee /etc/profile.d/rpi_tools.sh

sudo chown -R `whoami`:`whoami` /opt/depot_tools /opt/rpi_tools
source /etc/profile

sudo debootstrap --arch armhf --foreign --include=g++,libasound2-dev,libpulse-dev,libudev-dev,libexpat1-dev,libnss3-dev,libgtk2.0-dev jessie rootfs
sudo cp /usr/bin/qemu-arm-static rootfs/usr/bin/
sudo chroot rootfs /debootstrap/debootstrap --second-stage
find rootfs/usr/lib/arm-linux-gnueabihf -lname '/*' -printf '%p %l\n' | while read link target; do sudo ln -snfv "../../..${target}" "${link}"; done
find rootfs/usr/lib/arm-linux-gnueabihf/pkgconfig -printf "%f\n" | while read target; do sudo ln -snfv "../../lib/arm-linux-gnueabihf/pkgconfig/${target}" rootfs/usr/share/pkgconfig/${target}; done

Install wolfSSL

git clone https://github.com/wolfSSL/wolfssl.git
cd wolfssl
./autogen.sh
./configure --enable-opensslall --enable-keygen --enable-rsapss --enable-aesccm \
    --enable-aesctr --enable-des3 --enable-camellia --enable-curve25519 --enable-ed25519 \
    --enable-dtls --enable-certgen --enable-certreq --enable-certext --enable-tlsv10 \
    CFLAGS="-DWOLFSSL_PUBLIC_MP -DWOLFSSL_DES_ECB"
make
make check
sudo make install

Get WebRTC

fetch webrtc
cd src/
git checkout branch-heads/57
gclient sync

Get wolfSSL

git remote add wolf https://github.com/dgarske/webrtc.git
git fetch wolf
git checkout wolf_57
gclient sync

Build WebRTC

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

gn clean out/debug
gn gen out/debug --args='target_os="linux" target_cpu="arm" is_debug=true enable_iterator_debugging=false is_component_build=false is_debug=true rtc_build_wolfssl=true rtc_build_ssl=false rtc_ssl_root="/usr/local/include"'
ninja -C out/debug/ -t clean
ninja -C out/debug field_trial_default protobuf_lite p2p base jsoncpp

gn clean out/release
gn gen out/release --args='target_os="linux" target_cpu="arm" is_debug=false enable_iterator_debugging=false is_component_build=false rtc_build_wolfssl=true rtc_build_ssl=false rtc_ssl_root="/usr/local/include"'
ninja -C out/release/ -t clean
ninja -C out/release field_trial_default protobuf_lite p2p base jsoncpp

Extract the Static Libraries for Building IPOP Tincan

Get Tincan Codebase

Switch to the workspace directory:

cd ~/workspace/

Create ipop-project directory and download the Tincan repository there:

mkdir -p ipop-project/ && git clone https://github.com/ipop-project/Tincan.git ipop-project/Tincan

Copy the WebRTC Libraries to Tincan

First, create the required directories:

mkdir -p ipop-project/Tincan/external/3rd-Party-Libs/debug
mkdir -p ipop-project/Tincan/external/3rd-Party-Libs/release

These freshly built libraries will replace the existing libraries, if any.

Debug Libraries

ar -rcs ipop-project/Tincan/external/3rd-Party-Libs/debug/libjsoncpp.a webrtc-checkout/src/out/debug/obj/third_party/jsoncpp/jsoncpp/json_reader.o webrtc-checkout/src/out/debug/obj/third_party/jsoncpp/jsoncpp/json_value.o webrtc-checkout/src/out/debug/obj/third_party/jsoncpp/jsoncpp/json_writer.o

cp webrtc-checkout/src/out/debug/obj/webrtc/system_wrappers/libfield_trial_default.a ipop-project/Tincan/external/3rd-Party-Libs/debug
cp webrtc-checkout/src/out/debug/obj/webrtc/base/librtc_base.a ipop-project/Tincan/external/3rd-Party-Libs/debug
cp webrtc-checkout/src/out/debug/obj/webrtc/base/librtc_base_approved.a ipop-project/Tincan/external/3rd-Party-Libs/debug
cp webrtc-checkout/src/out/debug/obj/webrtc/p2p/librtc_p2p.a ipop-project/Tincan/external/3rd-Party-Libs/debug
cp webrtc-checkout/src/out/debug/obj/third_party/protobuf/libprotobuf_lite.a ipop-project/Tincan/external/3rd-Party-Libs/debug

Release Libraries

ar -rcs ipop-project/Tincan/external/3rd-Party-Libs/release/libjsoncpp.a webrtc-checkout/src/out/release/obj/third_party/jsoncpp/jsoncpp/json_reader.o webrtc-checkout/src/out/release/obj/third_party/jsoncpp/jsoncpp/json_value.o webrtc-checkout/src/out/release/obj/third_party/jsoncpp/jsoncpp/json_writer.o

cp webrtc-checkout/src/out/release/obj/webrtc/system_wrappers/libfield_trial_default.a ipop-project/Tincan/external/3rd-Party-Libs/release
cp webrtc-checkout/src/out/release/obj/webrtc/base/librtc_base.a ipop-project/Tincan/external/3rd-Party-Libs/release
cp webrtc-checkout/src/out/release/obj/webrtc/base/librtc_base_approved.a ipop-project/Tincan/external/3rd-Party-Libs/release
cp webrtc-checkout/src/out/release/obj/webrtc/p2p/librtc_p2p.a ipop-project/Tincan/external/3rd-Party-Libs/release
cp webrtc-checkout/src/out/release/obj/third_party/protobuf/libprotobuf_lite.a ipop-project/Tincan/external/3rd-Party-Libs/release

Now you can build IPOP Tincan binary on the Raspberry Pi 3, itself.