【发布时间】:2017-02-03 22:29:54
【问题描述】:
我使用的是 Windows 10。我想交叉编译一个 Rust 程序以在 armv7-unknown-linux-gnueabihf 上运行。 (armv7-unknown-linux-muscl 也可以接受,但似乎不可用。)
这是我的步骤:
- 安装
rustup rustup toolchain install stable-x86_64-pc-windows-gnurustup toolchain default stable-x86_64-pc-windows-gnurustup 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 的功能请求,也许在 repo 上做一个?有some chatter about semi-related aspects。 -
大部分结果都是针对嵌入式裸机 ARM GCC,它很容易以二进制形式 here 获得。那是
arm-none-eabi-gcc(或其他东西;这些目标三元组非常随意)。 -
对于通用打包的跨工具链,我会选择Linaro toolchain binaries。如果不清楚,您需要 i686_mingw32 一个。
-
啊哈!出于某种原因,我不得不unzip it as admin,但在那之后它起作用了。顺便感谢 mingw32 的提示。
标签: windows gcc arm rust cross-compiling