不支持 MSVC 工具链。请使用 GNU 工具链

MSVC toolchain is not supported. Please use GNU toolchain

我正试图在 CLion 中调试 Rust,当我遇到上述

我更新了我的工具链设置以使用建议的默认设置:

如何解决这个问题并让 CLion 能够调试 Rust 代码?

我做了一些搜索,但没有找到一个简单的答案(至少我可以很容易地理解)。

如有任何帮助,我们将不胜感激。

错误消息与 Rust 工具链有关,如果您还没有安装基于 GNU 的 Rust 工具链(在安装之前请确保您为您的环境选择了有效的基于 gnu 的工具链,如果您不确定,请阅读注意部分)。

> rustup toolchain install stable-x86_64-pc-windows-gnu

然后在解决这个问题的最简单方法之后将其设置为默认工具链

> rustup default stable-x86_64-pc-windows-gnu

注:工具链stable-x86_64-pc-windows为例;它是 64-bit Windows 通过稳定渠道的解决方案,不同的架构需要使用另一个工具链(详情:请遵循官方 jetbrains 指南来自 ),您也可以免费使用 nightly 或 beta。

以及 值得指出的是,Jetbarins 现在有一篇关于如何为 Rust 配置 Clion 的文章,其中包含一些关于哪些设置适用于 Rust 开发的提示。

Debugging Rust Code in CLion

特别是这段与问题相关:

On Windows, go to Settings | Build, Execution, Deployment | Toolchain and set either Cygwin or MinGW as your working environment. Then, run rustup toolchain list and check the first line: it should be one of the gnu versions matching the bitness of the debugger. For example, if you’re working on MinGW (32-bit), the default toolchain should be i686-pc-windows-gnu. If you’re on MinGW64, it should be x86_64-pc-windows-gnu. You can set the appropriate toolchain by running rustup default <toolchain_name>.