LANGUAGE ยป RUST
Compile
Single file โ
Most basic command for compiling:
shell
rustc main.rsMakefile โ
Single file, compile direct to executable.
makefile
build:
rustc main.rsCrate โ
From a rust script (without a main function), run this command to generate a library:
shell
rustc --crate-type=lib hello.rsThis generates a libhello.rlib file.
Then when compiling the script that uses libhello.rlib, we use the --extern option.
shell
rustc main.rs --extern rary=libhello.rlib && ./mainSample files for reference:
hello.rs
rust
pub fn greet() {
println!("Hello World!");
}main.rs
rust
mod hello;
fn main() {
hello::greet();
}