title: gcc: why is the -lm flag needed to link the math library?
body: <p>I just discovered that the <code>-lm</code> flag is needed by gcc in order to compile a program that refers a function from the math library. I'm wondering why an explicit linking flag isn't needed when compiling programs containing other libraries such as the time library. If I write a program where the <code>time()</code> function is called, it would compile with no problems even with no linking options. But a program with the math library involved just won't work without the <code>-lm</code> flag. </p>
  
  <p>Can anyone please explain the reason behind this behaviour? Thanks for your time.</p>