What are rustc -l and -L actually for?
⚓ Rust 📅 2026-06-04 👤 surdeus 👁️ 1I am compiling a crate with rustc only, purely out of curiosity, and I noticed something strange.
When linking a crate to a file, in extern crate mycrate and mycrate::myitem in the source, the only way to do it, seemingly, is by using rustc [OPTIONS] --extern mycrate=libmycrate.rlib, which works great, but -l never seems to work (rustc [OPTIONS] -l libmycrate.rlib), and I'm not even sure what -l even does (I know it links something, but what? It can't be external crates.) And what does -L do? It's something about the library search path, but what libraries is it searching for? It can't be external crates.
Nothing in the documentation (Rust reference, rustc book) really clarifies this for me.
An explanation on what these options do and how to use them would be excellent.
Thank you!
3 posts - 3 participants
🏷️ Rust_feed