title: Why is -L needed when -rpath is used?
body: <p>I find that the <code>-L</code> flag must be given when using <code>-rpath</code>. For instance:</p>
  
  <pre><code>gcc -o test test.o -L. -lmylib -Wl,-rpath=.
  </code></pre>
  
  <p>Why is the <code>-L</code> flag needed? What information more than the information from the h-files are needed at <em>compile</em> time?</p>
  
  <p>If I remove <code>-L</code>. I get the following message:</p>
  
  <pre><code>gcc -o test test.o -lmylib -Wl,-rpath=.
  /usr/bin/ld: cannot find -lmyLib
  </code></pre>
  
  <p>It's perfectly ok to remove both flags, though. Like this:</p>
  
  <pre><code>gcc -o test test.o -lmylib
  </code></pre>
  
  <p>Provided that libmyLib can be found in <code>/usr/lib</code>, that is. Why isn't <code>-L</code> needed now?</p>
  
  <p><em>This is a follow-up question to <a href="https://stackoverflow.com/a/8482308/1091780">https://stackoverflow.com/a/8482308/1091780</a>.</em></p>