Cross compile: ubuntu 19.04 -> raspbery pi zero w

I am trying to cross compile from ubuntu to raspberry pi zero.

Using target armv7-unknown-linux-gnueabihf following these instructions

When I run the executable I get: /home/pi/motion/cgi/bin/cgi: /lib/arm-linux-gnueabihf/libc.so.6: versionGLIBC_2.28’ not found (required by…`

Why?

The PI is running Raspbian GNU/Linux 9

$ arch
armv6l

I suspect the target is incorrect for the zero, or the libc versions do not match. This is my first attempt at cross compiling and I am out of my depth!

I was able to compile for raspberry zero using docker image for rust 1.35.0 using target arm-unknown-linux-gnueabihf

This image contains GLIBC 2.24

I used the following Dockerfile to build image

FROM rust:1.35.0

RUN mkdir -p /opt && \
  git clone --depth=1 https://github.com/raspberrypi/tools.git /opt/pi-tools

ENV PATH="/opt/pi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin:${PATH}"

RUN rustup target add arm-unknown-linux-gnueabihf

Use docker build to create image from that Dockerfile

# cd to the dir with the Dockerfile
docker build -t raspi-rust:1.35.0 .

After image was build I created container with the following command (cd to your projects directory before executing the following command)

# cd to your project`s dir
docker create \
  --interactive \
  --tty \
  --name raspi-build \
  --user "$(id -u)":"$(id -g)" \
  --volume "$PWD":/usr/src/proj \
  --workdir /usr/src/proj \
  raspi-rust:1.35.0 \
  /bin/bash

Then start container and you will be greeted with a bash prompt inside your project directory

docker start \
  --attach \
  --interactive \
  raspi-build

From here you can build the project for zero. I needed to use linker arm-linux-gnueabihf-g++ with following command:

RUSTFLAGS="-C linker=arm-linux-gnueabihf-g++" cargo build --target=arm-unknown-linux-gnueabihf

I used the target arm-unknown-linux-musleabi that, I believe, statically links in stdc so it does not get into version hell with dynamically linked libraries.

Sorry but I do not do docker, so I cannot parse your solution!

This is the wrong forum for just how much I hate docker. Deadly loathing.