6

使用 CLion 进行 Rust 编程

 1 year ago
source link: https://xugaoxiang.com/2022/12/01/clion-rust/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
  • windows 10 64bit
  • clion 2022.2.4

到官网下载最新版本 https://www.jetbrains.com/clion/,傻瓜是安装即可

安装成功后进行简单的配置,clion 默认是 C/C++ 开发的集成开发环境,所以需要安装插件来支持 rust 的开发

打开 File –> Settings –> Plugins

Marketplace 中搜索 rust 并安装

bd0f0c7b7cf63d2d.png

开发环境测试

重新打开 CLion,新建项目 New project

7b3fff2937e9cae5.png

然后在左侧栏中选择 Rust,右侧栏中填写项目名称及保存地址,clion 会自动检测到 rust 的工具链。如果系统中没有安装,请参考之前的博文 https://xugaoxiang.com/2022/11/12/rust-tutorial-1-hello-world/,最后,模板选择 Binary

c5c0bd8578d6681f.png
180ddbbfb1a38392.png

注意到,项目创建好后,clion 出来了一个提示框 No Cargo projects found,这个暂时不用理会,cargorust 项目构建的工具,后面我们会学到

源码 main.rs 文件中已经有了简单的打印语句,下面开始编译并执行,直接点击上方的三角形按钮

f694b7f7da41a683.png

可以看到代码被正确执行了,可执行文件存储在 target/debug/HelloWorld.exe

Rust系列教程

更多 Rust 教程,请移步

https://xugaoxiang.com/category/rust/


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK