guide: compiling rust programs for SBC4
Posted: Tue Sep 17, 2024 3:27 am
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:
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
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
Hope it helps someone