Compiling for First Gen RPI/PiZero(w)


Please forgive me if I’m not in the correct category, I’m new here!

I had a need to compile OpenCV for RPi 3B.
I decided that as I’m already spending the time to compile it I might as well provide this as a public service. Anyone could get up and running in the time it takes to install Docker and download my image, rather than wait for 3 hours of compilation.

I’m using a base image, but have hit a little roadblock.

I’m compiling on a RPi 3B, the image works fine on the 3B, but parts of it fail to run on a RPi Zero. Being new to Docker and, I mistakenly thought that using the resin/rpi-raspbian rather than one of the rpi-raspbian3 images would compile a more generic image (after all they included labels describing the CPU in the image!)

I’ve now trawled all over the Dockerfiles trying to find out what parameters should be used to compile for the PiZero/First generation RPi boards, but to no avail.
All I can find are Dockerfiles that curl pre-compiled binaries, but I’ve seen that resin have their own ARM build farm, so must be compiling for the different CPUs somewhere!

I would like to compile on my 3B rather than on a Zero as it already takes long enough to compile on the 3B for the 3B.

I’m not after a howto guide, just a point in the right direction.

If anyone is interested, OpenCV RPi 3 images are here.


Hi @SgtWilko
Can you provide the Dockerfile you are using to build the image?
If I understand correctly, you are able to compile OpenCV for the rpi3 but it fails for the zero and first generation rpi board?

Hi @lucianbuzzo,

What I want to do is compile for the PiZero, but I want to do the compilation on the RPi 3 (as my current build process is taking 3+hours on the RPi3).

I know you have an ARM build farm, and I was wondering what your build arguments were when compiling for the PiZero/BCM2835.

I feel like I’ve scoured a fair bit of the Github repos, but all I’ve found is precompiled binaries being curled

@SgtWilko Are you able to cross compile opencv for the PiZero on your development machine? Why do you need to compile on an rpi3 instead of a laptop/workstation for example?
If you could post the Dockerfile you are using, it would be very useful.

I’m sure I could cross compile, but I don’t leave my laptop on and I have this setup to auto build when new versions or base images are released.

Also, just like Resin, I’m trying to keep it all being built on Arm.

The docker file is here: