title: How to link a dynamic Rust library using only rustc and not cargo?
body: <p>My <code>main.rs</code> looks like</p>
  
  <pre class="lang-rust prettyprint-override"><code>// #[link(name = "lib")]
  extern "C" {
      fn hello();
  }
  
  fn main() {
      unsafe {
          hello();
      }
  }
  </code></pre>
  
  <p>And <code>lib.rs</code>:</p>
  
  <pre class="lang-rust prettyprint-override"><code>#[no_mangle]
  pub fn hello() {
      println!("Hello, World!");
  }
  </code></pre>
  
  <p>I have compiled <code>lib.rs</code> using <code>rustc --crate-type=cdylib lib.rs -o lib.so</code></p>
  
  <p>How do I link <code>lib.so</code> to <code>rustc main.rs</code> command ?</p>