How can I compile Rust code to run on a Raspberry Pi 2?

前端 未结 3 1215
旧时难觅i
旧时难觅i 2021-01-30 17:54

I recently acquired a Raspberry PI 2 and I want to run a Rust program on it.

Is there a guide/instructions how to cross compile Rust programs on Raspberry PI 2? I\'ve h

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-30 18:07

    The Rust compiler is not distributed as a cross-compiler for the Raspberry Pi, so it needs to be compiled as a cross compiler with rpi dev tools.

    1. Get rpi dev tools - git clone https://github.com/raspberrypi/tools.git ~/pi-tools

    2. get rust compiler from mozilla git repo and add rpi tools to the path export PATH=~/pi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin:$PATH

    3. Look for rusty-pi dir on your home ./configure --target=arm-unknown-linux-gnueabihf --prefix=$HOME/rusty-pi && make && make install

    4. Considering helloworld.rs -> % ~/pi-rust/bin/rustc --target=arm-unknown-linux-gnueabihf -C linker=arm-linux-gnueabihf-g++ helloworld.rs

    It will produce an executable.

提交回复
热议问题