我正在使用Windows 10。我想要交叉编译一个Rust程序,以在 armv7-unknown-linux-gnueabihf
上运行。(armv7-unknown-linux-muscl
也可以接受,但似乎不可用。)
以下是我的步骤:
- 安装
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 cross compiler windows
似乎有一些有希望的线索,可以让您下载预构建的编译器以用作链接器。你在这里想问什么问题?如果这是对rustup的功能请求,或许可以在库的存储库上创建一个请求?关于半相关方面也有一些交流。详见: https://github.com/rust-lang-nursery/rustup.rs/issues/486。 - Shepmasterarm-none-eabi-gcc
(或者其他什么;这些目标三元组非常任意)。 - Timmmm