[[Rust]], being a [[Compiled Languages|compiled language]], has **clearly differentiated compilation and running steps**. The compilation is done using the [[rustc]] tool: ```shell rustc main.rs ``` Running, on the other hand, is done using the generated binaries. ```shell ./main ``` Rust is an [[Ahead-Of-Time Compilation|ahead-of-time compiled]] language, so the generated binaries are self-contained and can be run in a machine with no Rust runtime installed (if the architecture matches). ## Compiling using [[Cargo]] Most of the times, when trying to compile a complete project, it is a good idea to delegate the use of `rustc` to [[Cargo]]. To do so, navigate to a [[Cargo]] project and run: ```shell cargo build [--release] ``` To generate the binaries in the `./target` directory. There, you can find different directories for different configurations like `debug`, `release`, etc. When using the `--release` flag, [[Cargo]] will compile the code with optimizations. It will run faster, but will take longer compile. It is also important to note that there is a shorthand to both compile and run the code using: ```shell cargo run ```