在 Windows 中为 Cortex-M4 交叉编译 Rust 项目

问题描述

我很难在 Windows 中为 Cortex-M4 交叉编译嵌入式 Rust 项目。通过Embedded Rust book,我了解到需要安装必要的目标和工具链。我正在尝试按如下方式执行此操作(在 Windows cmd 会话中):

> rustup target add thumbv7em-none-eabihf
info: component 'rust-std' for target 'thumbv7em-none-eabihf' is up to date

> rustup toolchain install stable-thumbv7em-none-eabihf
info: syncing channel updates for 'stable-thumbv7em-none-eabihf'
info: latest update on 2021-05-10,rust version 1.52.1 (9bc8c42bb 2021-05-09)
error: target 'thumbv7em-none-eabihf' not found in channel.  Perhaps check https://doc.rust- 
lang.org/nightly/rustc/platform-support.html for available targets

我不明白上面的错误信息。我检查了提供的链接,似乎 cortex-m4 是“第 2 层”目标。我怀疑我使用了错误的工具链前缀,例如“稳定”?

当然,如果我跳过上面的内容并尝试使用 cargo build 构建项目,它会在查找错误链接器可执行文件时失败,即:

error: linker `link.exe` not found
  |
  = note: The system cannot find the file specified. (os error 2)

note: the msvc targets depend on the msvc linker but `link.exe` was not found

note: please ensure that VS 2013,VS 2015,VS 2017 or VS 2019 was installed with the Visual C++ option

附带说明,该项目在 Linux 和 Macos 上构建良好。

有人能解释一下如何正确设置工具链和目标吗?不幸的是,Embedded Rust 一书没有深入探讨特定于操作系统的工具链安装。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)