rust 1.安装

安装

下载地址:https://www.rust-lang.org/learn/get-started

rust安装有一个先决条件:cpp的编译器

在windows下进行Rust开发,编译器有两个选择要么是msvc,要么是MinGW(GNU)。这是两个是不兼容的编译器,用了msvc编译的库,那么这个库也只能引用msvc编译的依赖库;gnu也是一样。
既然在windows下编写,仍然建议使用msvc编译器。如果你已经出现两个版本了请先卸载rust,再重新安装

shellrustup self uninstall

安装完成后,查看rust版本:rustc --version

开发

VS Code 2022

插件:rust-analyzer

Hello World

> mkdir hello_world
> cd hello_world
> code .

进入vscode创建main.rs文件

fn main() {
  println!("Hello World!");
}

ctrl+~唤醒terminal,编译main.rs

rustc main.rs

编译后就会生成main.exe可执行文件

> .\main.exe
Hello World!

编译异常

如果在rustc编译的时候出现以下异常

> rustc .\main.rs
error: linker `link.exe` not found
  |
  = note: program not found

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

note: please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option.

note: VS Code is a different product, and is not sufficient.

error: aborting due to 1 previous error

是因为缺少了windows SDK或msvc build tools 可以通过vs install安装

相关推荐

  1. rust 1.安装

    2024-06-11 07:04:02       35 阅读
  2. Rust 安装

    2024-06-11 07:04:02       53 阅读
  3. Rust】——不安全Rust

    2024-06-11 07:04:02       25 阅读
  4. Rust 初体验1

    2024-06-11 07:04:02       46 阅读
  5. Rust Learning Day1

    2024-06-11 07:04:02       32 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-06-11 07:04:02       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-06-11 07:04:02       106 阅读
  3. 在Django里面运行非项目文件

    2024-06-11 07:04:02       87 阅读
  4. Python语言-面向对象

    2024-06-11 07:04:02       96 阅读

热门阅读

  1. 大学生如何学习node.js?

    2024-06-11 07:04:02       28 阅读
  2. MYSQL

    MYSQL

    2024-06-11 07:04:02      31 阅读
  3. MacOS升级ruby版本

    2024-06-11 07:04:02       32 阅读
  4. GitHub工程git merge出现冲突处理方式

    2024-06-11 07:04:02       33 阅读
  5. PostgreSQL的视图pg_roles

    2024-06-11 07:04:02       31 阅读
  6. bexcel

    2024-06-11 07:04:02       29 阅读
  7. 需要安排几位师傅加工零件?c++

    2024-06-11 07:04:02       29 阅读
  8. [FFmpeg学习]初级的SDL播放mp4测试

    2024-06-11 07:04:02       33 阅读
  9. linux:centos7升级glibc到2.36

    2024-06-11 07:04:02       34 阅读
  10. Python 虚拟环境 + 嵌入式 部署方案

    2024-06-11 07:04:02       35 阅读