Correct way to setup 'armhf' cross stage/compile?

what is the ‘correct’ way to setup cross compilation on amd64 to target armhf ?

  1. snapcraft --target-arch=armhf
    this gives me an error saying i should do the following:
    dpkg --add-architecture armhf

if I run the command this message says… i get tons of 404’s when it searches for packages… (why would it suggest something that doesn’t work?)

so after dpkg --remove-architecture armhf i manually edited the sources.list add added the following:

deb [arch=armhf] xenial main
deb-src [arch=armhf] xenial main
deb [arch=armhf] xenial-updates main
deb-src [arch=armhf] xenial-updates main
deb [arch=armhf] xenial-security main
deb-src [arch=armhf] xenial-security main

Is this list complete?

  1. in my snapcraft.yaml all of my stage-packages are specified as follows

    • libcurl3:armhf
    • libssl1.0.0:armhf

It seems to be working, , but I just want to know if I am missing something…

the current issue I have is that there exists a package (iperf3) that works on the armhf (i installed it via apt-get outside of the snap app armor and it works) . when i add this:

  • iperf3:armhf

to my snapcraft.yaml i get the following error:

Error downloading stage packages for part ‘mypartname’: The package ‘iperf3:armhf’ was not found.
You may need to add support for this architecture with ‘dpkg --add-architecture armhf’.

if I remove the :armhf it builds the package, but the binary included in the snap is the wrong architecture.

So… is my cross staging/compiling setup correct? I suspect i might be missing a source… or maybe im using the wrong list of sources and just got lucky before.

1 Like

Hey, were you able to find a solution? I am experiencing a similar problem.

my setup works - however, I can’t exactly say what I did to get it to work as I had to do a lot of traial and error… From my experience snap is really unpleasant to configure cross compiling… i might try and start over again using the newer features to see if there was any improvement… however this post seems like a typical ‘use case’ that should just be documented as a how to guide… but most of the snap documentation is(was?) useless except for the most trival of examples…

Thanks, if anything comes to mind or you ever end up needing to set it up I’d appreciate any tips.

So far the solution that works for me is running it natively on a Raspberry Pi host which isn’t ideal. I’m trying to setup a docker based solution on Circle CI but I’m having some issues with that as well.


Not sure if this is still a problem for you, but see my answer to a similar problem: Stage-Packages with --target-arch

Not sure if you ran into this problem, but you may need to use quotes around the package name, i.e. instead of stage-packages: [iperf3:armhf], you need to do stage-packages: ["iperf3:armhf"].

For reference, this is my (minimal) /etc/apt/sources.list that works for my cross-compiled stage-packages (and also for your iperf3 package):

deb [arch=amd64] xenial main restricted
deb [arch=amd64] xenial-updates main restricted
deb [arch=amd64] xenial universe
deb [arch=amd64] xenial-updates universe
deb [arch=amd64] xenial multiverse
deb [arch=amd64] xenial-updates multiverse
deb [arch=amd64] xenial-backports main restricted universe multiverse
deb [arch=amd64] xenial-security main restricted
deb [arch=amd64] xenial-security universe
deb [arch=amd64] xenial-security multiverse

deb [arch=armhf,arm64] xenial main universe
deb [arch=armhf,arm64] xenial-security main universe
deb [arch=armhf,arm64] xenial-updates main universe
deb [arch=armhf,arm64] xenial-backports main universe

Note that I also specify for arm64 so I can also cross compile for arm64, this isn’t necessary if you’re just building for armhf. Also note that you don’t need the deb-src lines if you’re just installing the package.

I was able to build a snap with the following minimal part definition (the rest of the snapcraft.yaml removed for clarity):

    plugin: nil
      - on amd64 to armhf:
          - "iperf3:armhf"
      - else:
        - "iperf3"

Also note that I invoked snapcraft as snapcraft --target-arch=armhf on an Ubuntu 16.04 classic VM and it downloaded the correct package and installed it in the snap.