rust学习之开发环境

工具链

安装

shell 复制代码
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

确认

shell 复制代码
ethan@G5000:~$ rustc --version
rustc 1.89.0 (29483883e 2025-08-04)

创建工程

创建

shell 复制代码
cargo new demo

上述,demo为工程名称。

调试

shell 复制代码
cargo run

静态编译

目前计划使用rust编写一些小工具。考虑使用静态编译,已方便使用。

配置工程

添加文件.cargo/config.toml

shell 复制代码
[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"

安装依赖

shell 复制代码
sudo apt-get install musl-tools
rustup target add x86_64-unknown-linux-musl
cargo build --release --target x86_64-unknown-linux-musl

确认

shell 复制代码
ethan@G5000:~/demo$ ldd ./target/x86_64-unknown-linux-musl/release/demo
        statically linked

docker

shell 复制代码
# 使用 muslrust 镜像
docker run --rm -it \
  -v "$(pwd)":/app \
  -w /app \
  clux/muslrust:stable \
  cargo build --release

交叉编译

shell 复制代码
rustup target add x86_64-pc-windows-gnu
cargo build --release --target x86_64-pc-windows-gnu
相关推荐
sycmancia10 小时前
Qt——对话框及其类型
开发语言·qt
趙卋傑10 小时前
测试开发场景下常见的 MCP 服务
开发语言·python·测试工具·ai编程
@atweiwei10 小时前
langchainrust:Rust 版 LangChain 框架(LLM+Agent+RAG)
开发语言·rust·langchain·agent·向量数据库·rag
阿里嘎多学长10 小时前
2026-04-11 GitHub 热点项目精选
开发语言·程序员·github·代码托管
嵌入式×边缘AI:打怪升级日志10 小时前
Makefile 完全学习笔记:从入门到通用模板解析
笔记·学习
yugi98783810 小时前
基于最大信息熵的粒子群优化算法图像分割(MATLAB实现)
开发语言·算法·matlab
yaoxin52112310 小时前
376. Java IO API - 使用 Globbing 和自定义 Filter 过滤目录内容
java·开发语言·python
ACGkaka_11 小时前
ES 学习(九)从文本到词元:分词器如何“拆解“你的数据
大数据·学习·elasticsearch
飞翔的SA11 小时前
全程 Python:无需离开 Python 即可实现光速级 CUDA 加速,无需c++支持
开发语言·c++·python·nvidia·cuda
南無忘码至尊11 小时前
Unity学习90天-第1天-认识Unity并书写我们的第一个脚本
学习·unity·游戏引擎