This is a quick guide on how to set up cross-compilation of Rust programs, where you are using Rust libraries that have system level dependencies, like openssl.
We think it's easiest to cross-compile on a 32 bit linux machine. Could be that 64 bit works as well, but since the arm is 32 bit..
Set up cross-compilation according to https://github.com/Ogeon/rust-on-raspberry-pi
It is a bit of work. but make sure you follow the instructions, and keep to the 32 bit options.
Additionally, we have to extend that arm toolchain with the system dependencies: openssl and zlib.
Get these packages either from the raspberry, or download them online.
If you do "dpkg show packagename" on the raspberry, you'll see an output like this:
Filename: pool/main/o/openssl/libssl1.0.0_1.0.1e-2+rvt+deb7u17_armhf.deb
You should be able to find a match for that under:
http://ftp.debian.org/debian/pool/
If not, see if it is still on the raspberry under /var/cache/apt/archive.
If not, just google the filename online.
When you have the dependencies, extract them into the arm toolchain:
# cd into the sysroot of the arm toolchain
cd /home/vagrant/pi-tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/arm-bcm2708hardfp-linux-gnueabi/sysroot/
# use `ar` to extract contents out of the deb files
ar p libssl1.0.0_1.0.1e-2+rvt+deb7u17_armhf.deb data.tar.gz | tar zx
ar p libssl-dev_1.0.1e-2+rvt+deb7u17_armhf.deb data.tar.gz | tar zx
ar p zlib1g_1.2.7.dfsg-13_armhf.deb data.tar.gz | tar zx
ar p zlib1g-dev_1.2.7.dfsg-13_armhf.deb data.tar.gz | tar zx
Now you're ready to build the project:
cd ~/projects/rust-example
cross32 build
First time it will take a while. Afterwards you can find the executable for arm in here:
target/arm-unknown-linux-gnueabihf/debug/