rustc command |
cargo build command |
---|---|
It is used to compile a single Rust source file or crate | It is used to compile the entire Rust project and its dependencies |
Example: rustc <source-file> or rustc <crate> |
Example: cargo build |
It does not handle dependency management | It handles dependency management through Cargo and the Cargo.toml file |
You need to manage dependencies and configuration manually. | Configuration is manged using the Cargo.toml file |
It requires explicit compilation of dependencies | It is automatically managed and compiles dependencies |
It produces an executable or library file directly | I produces build artifacts in the target directory |
It does not perform incremental builds by default | It performs incremental builds by default |
rustc can manually specify optimization flags | cargo build applies optimization based on the build profile in Cargo.toml |
rustc does not execute build scripts | cargo build executes build scripts specified in Cargo.toml |
It relies on system Rust installation and environment | It uses the project-specific Rust toolchain managed by Cargo |
-
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to Rust,
- Rust: Cargo Init vs Cargo New Command
- Rust: Write and Run Hello World! Program Example
- How to Split a String using Rust Language
- How to Sort a Vector in Rust with Examples
- Fix: error: could not find `Cargo.toml` in Users or any parent directory
- How to uninstall Rust Language from Mac/Linux/Ubuntu
- How to update Cargo (Rust Lang)
- Fix: rust-analyzer failed to discover workspace [Visual Studio Code]
- How to install Rust using rustup on macOS/Linux/Ubuntu
- Cargo Watch: To Recompile Rust Project Automatically
- Difference between rustc and cargo build commands
- How to Split a String by Space in Rust
- How to know Rust is Installed on Mac?
- Rust: zsh: no such file or directory: ./main
- How to update Rust on Mac/Linux
- List of Rust Cargo Commands
- How to find version of Cargo in Rust
- Fix: error: mismatched closing delimiter } [Rust]
More Posts:
- cURL: Show Request and Response Headers - cURL
- How to Save Jupyter Notebook as PDF - Python
- Install Golang (Go) on Ubuntu - Ubuntu
- Disable Apps from Opening on Mac Startup (Login items) - MacOS
- Fix error The tool was unable to install the Web Server (IIS) Role during SharePoint 2019 Setup - SharePoint
- How to Kill Terminal Process in Mac - MacOS
- What is Markdown in Jupyter Notebook with Examples - Python
- Clone Bitbucket repo in VS Code - HowTos