如何编译 Rust 代码以在 Raspberry Pi 2 上运行? [英] How can I compile Rust code to run on a Raspberry Pi 2?
本文介绍了如何编译 Rust 代码以在 Raspberry Pi 2 上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我最近购买了一个 Raspberry PI 2,我想在它上面运行一个 Rust 程序.
I recently acquired a Raspberry PI 2 and I want to run a Rust program on it.
是否有指南/说明如何在 Raspberry PI 2 上交叉编译 Rust 程序?我听说过在 RPi 或 Arduino 上运行 Rust,虽然不是最近.
Is there a guide/instructions how to cross compile Rust programs on Raspberry PI 2? I've heard about running Rust on RPi or Arduino, although not recently.
我想要一个在 Raspberry Pi 2 上运行的 Hello World
等效 Rust 程序.它不必是字面意义上的 Hello World 程序,只需具有类似的低复杂度的程序即可.
I want a Hello World
equivalent Rust program running on Raspberry Pi 2. It doesn't have to be a literal Hello World program, just something that is of similar low complexity.
推荐答案
我们有 生锈 现在.
$ rustup target add arm-unknown-linux-gnueabihf
$ sudo apt-get install gcc-arm-linux-gnueabihf
$ echo '[target.arm-unknown-linux-gnueabihf]' >> ~/.cargo/config
$ echo 'linker = "arm-linux-gnueabihf-gcc"' >> ~/.cargo/config
$ cd <project dir>
$ cargo build --target=arm-unknown-linux-gnueabihf
这篇关于如何编译 Rust 代码以在 Raspberry Pi 2 上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文