guide: compiling rust programs for SBC4

General PhidgetSBC Discussion.
Post Reply
max97
Fresh meat
Posts: 1
Joined: Tue Sep 17, 2024 3:09 am
Contact:

guide: compiling rust programs for SBC4

Post by max97 »

Hi, I managed to compile some rust programs for the SBC4.
I'm writing these notes in case they help others.

The SBC4 is not very powerful. If your program is small enough and with close-to-zero dependencies, you can install a rust compiler there simply follow instructions on the official website. Compiling will be a bit slow, but for small projects it's enough.

However, for a more complex program, you need to cross-compile it, i.e. use the power of another more powerful computer to create an executable for the SBC, then copy the executable to the SBC and simply run it there.

There's a tool called cross that helps with this. It internally creates a container for the target platform, automatically runs the compilation inside the container and generates the executable that you will be able to run on the SBC4.

After installing it as in the official guide,
compile the project for the SBC4 architecture with this:

Code: Select all

cross build --target armv7-unknown-linux-gnueabihf --release
Sometimes I encountered some strange libc error. You need to clean up the build directory and its cache files by running "cross clean". After this, recompile the project with the previous command.

Hope it helps someone :)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests