如何在 Rocky Linux 9 上安装 Rust 编程语言
admin
2023-07-31 03:33:00
0

Rust 是由 Mozilla 开发的免费、开源、多范式、通用编程语言. 这种语言具有许多特性,例如安全性、内存和并发性。开发人员使用 Rust 创建范围广泛的新软件应用程序,例如游戏引擎、操作系统、文件系统、浏览器组件和虚拟现实模拟引擎。Rust-programming-languageRust-programming-language

在 Rocky Linux 9 上安装 Rust 编程语言

步骤 1. 第一步是将您的系统更新到最新版本的软件包列表。为此,请运行以下命令:

sudo dnf check-update
sudo dnf install dnf-utils
sudo dnf install epel-release
sudo dnf install cmake gcc make curl clang

步骤 2. 在 Rocky Linux 9 上安装 Rust 编程语言。

默认情况下,Rust 在 Rocky Linux 9 基础存储库中不可用。现在运行以下命令,从官方页面下载最新的稳定版本安装程序 Rust 包到您的系统:

curl --proto \'=https\' --tlsv1.2 -sSf https://sh.rustup.rs | sh

在您的输出中,您将看到:

home directory, located at:

  /root/.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory located at:

  /root/.cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo\'s bin directory, located at:

  /root/.cargo/bin

This path will then be added to your PATH environment variable by
modifying the profile files located at:

  /root/.profile
  /root/.bash_profile
  /root/.bashrc

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:

   default host triple: x86_64-unknown-linux-gnu
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1

键入 1 并按 Enter 开始安装并激活 Rocky Linux 9 上的 Rust 环境:

source ~/.profile
source ~/.cargo/env

验证安装的 Rust 版本构建:

rustc -V

步骤 3. 创建示例 Rust 应用程序。

首先,您需要使用以下命令为您的 Rust 项目创建一个目录:

mkdir rust-projects

接下来,切换到您的 Rust 项目目录:

cd rust-projects

现在使用以下命令创建示例应用程序:

nano helloworld.rs

添加以下文件:

fn main() {
println!(\"Hello World, this is a test provided by idroot.us\");}

之后,编译上面创建的应用程序:

rustc helloworld.rs

要在 Rocky Linux 上运行您使用 Rust 创建的应用程序,请使用以下命令运行该程序:

./helloworld

输出:

Hello World, this is a test provided by idroot.us

感谢您使用本教程在 Rocky Linux 9 系统上安装 Rust 编程语言。如需更多帮助或有用信息,我们建议您查看Rust 官方网站。

相关内容

热门资讯

Windows 11 和 10... Windows 11/10 文件夹属性中缺少共享选项卡 – 已修复 1.检查共享选项卡是否可用 右键...
事件 ID 7034:如何通过... 点击进入:ChatGPT工具插件导航大全 服务控制管理器 (SCM) 负责管理系统上运行的服务的活动...
Radmin VPN Wind... Radmin VPN 是一款免费且用户友好的软件,旨在牢固地连接计算机以创建一个有凝聚力的虚拟专用网...
Hive OS LOLMine... 目前不清退的交易所推荐: 1、全球第二大交易所OKX欧意 国区邀请链接: https://www.m...
如何修复 Steam 内容文件... Steam 内容文件锁定是当您的 Steam 文件无法自行更新时出现的错误。解决此问题的最有效方法之...
Hive OS 部署 PXE ... 目前不清退的交易所推荐: 1、全球第二大交易所OKX欧意 国区邀请链接: https://www.m...
如何在电报Telegram中隐... 点击进入:ChatGPT工具插件导航大全 在Android上的电报中隐藏您的电话号码 您可以通过切换...
在 iCloud 上关闭“查找... 如果您是 Apple 的长期用户,您肯定会遇到过 Find My 应用程序,它本机安装在 iPhon...
farols1.1.501.0... faro ls 1.1.501.0(64bit)可以卸载,是一款无需连接外部PC机或笔记本计算机即可...
如何在Instagram上扫描... 如何在Instagram上扫描名称标签/ QR? 总而言之,您可以通过大约四种不同的方法来扫描这些I...