如何在Win11系统中使用ubuntu(WSL)终端编译 Rust 程序

第一步:安装 WSL

参考微软提供的官方指南

在管理员模式下打开 PowerShellWindows 命令提示符,方法是右键单击并选择"以管理员身份运行",输入 wsl --install wsl --update命令,然后重启计算机。

如遇其他问题,可参考CSDN文章解决。

第二步:安装 ubuntu22.04

从windows store 中下载安装

第三步:修改国内源

打开文件资源管理器,打开左侧的Linux文件夹,定位到 etc/apt/目录,将 sources.list 复制保存为 sources.list.bk

用记事本程序打开 sources.list,将其中内容修改为国内源,如清华源:

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse

deb http s://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse

第四步:启动 ubuntu22.04并更新

设置用户名、密码。sudo apt update && sudo apt upgrade -y 更新 ubuntu 系统。

第五步:安装所需软件包

sudo apt install cargo

第六步:使用WSL终端编译Rust程序

在win11系统下,打开 VScode,即可使用 WSL 终端编译 Rust 程序 。

相关推荐
令狐少侠20117 小时前
Linux 系统部署夜莺 nightingale 监控公司的watchdog
linux·运维·服务器
信工 18027 小时前
RK3588系统烧录后扩容
linux·rk3588
Jay Chou why did8 小时前
程序启动地址0x80000000
linux
落笔映浮华丶8 小时前
c程序的翻译过程 linux版
linux·c语言
阮松云8 小时前
code-server 配置maven
java·linux·maven
木木木一8 小时前
Rust学习记录--C11 编写自动化测试
java·学习·rust
Pomelo_刘金8 小时前
Linux I/O 方式进化史(内核/性能视角):从“睡死”到“就绪队列”再到“完成队列”
linux
提伯斯6469 小时前
解决 PX4 + ROS px4ctrl 「No odom!」自动起飞失败问题
linux·ros·px4·fastlio·mid360·egoplanner
牛奶咖啡139 小时前
shell脚本编程(八)
linux·shell脚本编程·while循环语句·计数器控制的while循环·标志控制的while循环·until循环·select循环菜单
Q16849645159 小时前
知识点-创建、查看和编辑文本文件
linux·运维