WSL (Linux)配置 Rust 开发调试环境
-
安装 Rust:安装 Rust 环境 - Rust语言圣经(Rust Course)
除了执行以上步骤,还得安装编译工具:
bashsudo apt-get update sudo apt-get install build-essential
-
配置 VSCode:墙推 VSCode! - Rust语言圣经(Rust Course)
-
安装调试工具:
bashsudo apt install lldb
安装 CodeLLDB 插件,如果有报错,根据报错提示下载好.VSIX文件以后使用
Install from VSIX...
的 VSCode 命令。在项目目录下命令行运行
cargo build
命令构建调试用二进制文件。按 F5 运行调试,如果报错,则根据提示配置
launch.json
文件,比如:json{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "lldb", "request": "launch", "name": "Debug", "program": "${workspaceFolder}/target/debug/<executable_file>", "args": [], "cwd": "${workspaceFolder}" } ] }