我使用的是Windows 10.我想交叉编译Rust程序在armv7-unknown-linux-gnueabihf
上运行。 (armv7-unknown-linux-muscl
也是可以接受的,但它似乎没有用。)从Windows到ARM Linux的交叉编译生锈
这里是我的步骤:
- 安装
rustup
rustup toolchain install stable-x86_64-pc-windows-gnu
rustup toolchain default stable-x86_64-pc-windows-gnu
rustup target add armv7-unknown-linux-gnueabihf
编辑我的
./cargo/config
文件以包含:[build] target = "armv7-unknown-linux-gnueabihf"
cargo build
这编译一切都很好,但是当涉及到连接它给出了这样的错误:据我已经能够确定
error: could not exec the linker `cc`: The system cannot find the file specified. (os error 2)
,这是因为Rust没有自己的链接器,而是使用GCC。显然,我需要为此提供自己和这个添加到./cargo/config
文件:
[target.armv7-unknown-linux-gnueabihf]
linker = "c:/path/to/my/gcc/cross/compiler"
是吗?如果是这样的话,我可以在Windows下载这样一个交叉编译器,并且为什么不安装rustup
?不得不自己编译GCC的交叉编译版本是交叉编译C/C++程序最大的麻烦。 Rustup真的不会让这更容易吗?
为'arm交叉编译器窗口“执行互联网搜索似乎有许多有前景的潜在客户,可以让您下载预构建的编译器作为链接器。你想问什么问题?如果这是一个生锈的功能请求,也许在回购上做一个? [有关半相关方面的一些喋喋不休](https://github.com/rust-lang-nursery/rustup.rs/issues/486)。 – Shepmaster
大部分结果都是针对嵌入式裸机ARM GCC的,这些二进制形式很容易获得[https://launchpad.net/gcc-arm-embedded]。那就是'arm-none-eabi-gcc'(或者其他的东西;这些目标三元组是非常随意的)。 – Timmmm
对于通用打包的交叉工具链,我会选择[Linaro toolchain二进制文件](http://www.linaro.org/downloads/)。如果不清楚,你会想要一个i686_mingw32。 – Notlikethat