Building Rust Apps on Ubuntu for the L5

I am trying to build a GTK app for the L5 using rust. At the moment I am building on Ubuntu and just moving my app to the L5 to test it every now and again.

Everything is working fine on the Ubuntu machine however when I move the files to the L5 I am getting the following error:

-bash: ./my-gtk-app: cannot execute binary file: Exec format error

This is probably because I am using the wrong build target when I am compiling my app. At the moment the target I have found from google is: x86_64-unknown-linux-musl however this is producing the same error.

Does anyone know how to configure my rust project so that it will run on the L5 once compiled?

I am not 100% sure but my guess is aarch64-unknown-linux-gnu.

FYI, I found it listed on this article -

So in the end I decided to just setup a development environment on the phone and scp files over for testing. There is probably a much simpler solution than what I have here however I don’t really know anything about cross compilation and the errors I was running into proved too difficult for me to handle in a timely manner.

After reading through the article linked above and a number of other articles online I was running into linker errors that I did not know how to fix.

If anyone runs across this thread who can simplify this answer I’m sure future readers would be very appreciative.

These are the steps I took to get rust and gtk working on the L5. At present my GTK app is building and running on the L5 when I scp the rust files over.

Install rust:

curl --proto '=https' --tlsv1.2 -sSf | sh

If you are building GTK4 to use with anything the next 5 instruction blocks seem to be what you need:

Install dependencies:

sudo apt install graphene cmake libjpeg-dev libxml2-dev libgstreamer-plugins-bad1.0-dev

Download the latest meson from GitHub:

git clone

Download latest version of GTK:
At the time of writing it was 4.8. The current list can be found here. Even numbers are stable odd numbers are non stable (i.e. 4.8 stable, 4.9 non stable)


Unpack GTK:

tar xf gtk-4.8.0.tar.xz

Build GTK:

cd gtk-4.8.0
<path to where you cloned meson>/ _build .
cd _build
ninja (this step took about 3 hours for me)
meson test
sudo ninja install

Build your rust project:

cargo run
1 Like

I use mozilla-rustc directly from the repos on the L5.

The only way to set up cross-compilation is to bother with rustup, and then you still have to solve the problem of cross-arch C libraries, so I never bothered. If I need to “cross-compile”, I use qemu (a podman container, qemu-user, and the correct ARM64 binfmt incantation) to compile in a virtualized CPU.