微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决在 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 举报,一经查实,本站将立刻删除。