我用的是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
-
编辑my
./cargo/config
文件以包含:[build] target = "armv7-unknown-linux-gnueabihf"
一百
这可以很好地编译所有内容,但在链接时会出现以下错误:
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++程序的最大痛苦.Rustop真的没有让这变得更容易吗?