Cross Compiling MX Linux to RPI Zero 2

Hello all, I am very new to rust and cargo and the world of crates. I found an application I want to install on my pi but it would overheat and run out of memory when I tried to install locally so now I'm in the process of trying to compile it on my laptop and transfer it to my pi.

Currently I am trying this command:

cargo build --release --target=aarch64-unknown-linux-gnu

However I keep getting an error with openssl being unable to install. So I've been looking at setting the OPENSSL_DIR environment variable although I'm not sure where to set it or what to set it to.

The program compile and runs on my laptop I'm just having trouble compiling it to a target os, which I believe I have the correct one.

This is the article I've been following as a guide.

Any help would be much appreciated, also let me know if more details would need to be provided.

Cross compiling generally gets tricky when you get to C dependencies. I recommend using one of these two helper tools:

Cargo-Zigbuild is faster and easier, but doesn't support cross testing. Cross needs docker to build, and can use a lightweight user mode qemu instance to run the cross compiled tests.

OpenSSL in general is quite annoying. For cross there are special instructions on their github wiki about it.

You might prefer to do a musl cross build rather than glibc, that creates a static binary, so it is easier to make it portable.

(Oh and you should probably fix the cooling on your pi. I run mine in a passive metal chassis, where the chassis acts as a heatsink. Quiet and cool. Can't so much about the memory though.)

1 Like

Thank you! I'll give both of those a try. I went through cross a bit but I'm getting stuck with an executable that I can't run on my pi or my laptop and I'm not really sure what happened so I'll try Zigbuild.

And yeah I really need something to cool my pi, metal chasis is a pretty good idea I'll see if I have something lying around.

Just want to put this here for a closed post, but I was able to successfully cross compile using cross and docker. What I had done wrong mostly was install the wrong architecture versions for the dependencies on my laptop before switching over which made the executable unrecognizable on an arm64v8 chip specifically.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.