A docker image containing an emulated debian environment for armv7 platform is used here to install additional toolchain to cross compile wtihin container.

Prerequisits

Before running the container, the host system must have the emulation support installed and registered in the Linux kernel:

sudo apt-get install qemu-user-static binfmt-support

Furthermore, the emulator must be registered in the kernel to execute a armv7 binary with qemu:

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

Build docker image

As base image with a Debian environment for armv7 is used and extended by the compiler tool chain. Dockerfile:

FROM balenalib/armv7hf-debian

RUN [ "cross-build-start" ]

RUN apt-get update
RUN apt-get install build-essential cmake --no-install-recommends

RUN [ "cross-build-end" ]

Build docker image with the tag 'cross-compile':

docker build -t cross-compile ./

Mount sources into and run container:

docker run -it -v /workspace/sources:/sources --rm --name crosscompiler cross-compile:latest

After the container is running and the shell opens, cd into /sources and build it:

cd /sources
mkdir build && cd build
cmake ..
cmake --build .

Previous Post Next Post