title: error In using math function in gcc?
body: <p>When I am passing constant value in log2() as follow</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include&lt;math.h&gt;
  
  int main(int argc, char* argv[]) 
  {
  int var;
  var= log2(16);
  printf("%d",var);
  return 0;
  }
  </code></pre>
  
  <p>gcc prog.c (NO Error)
  4</p>
  
  <p>But when I am passing variable in function log2(var) gives error
  undefined reference to `log2' I require to link library i.e. -lm</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include&lt;math.h&gt;
  
  int main(int argc, char* argv[]) 
  { 
  int var,i;
  i= log2(var);
  printf("%d",i);
  return 0;
  }
  </code></pre>
  
  <p>Gives error </p>
  
  <pre><code>undefined reference to `log2'
  </code></pre>