title: Undefined Reference error for power function in C
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4174080/problem-using-pow-in-c">Problem using pow() in C</a><br>
    <a href="https://stackoverflow.com/questions/8671366/undefined-reference-to-pow-and-floor">Undefined reference to <code>pow&amp;#39; and</code>floor&#39;</a>  </p>
  </blockquote>
  
  
  
  <p>I am using gcc 4.6.1.</p>
  
  <p><strong>Code snippet:</strong></p>
  
  <pre><code>int main(void)
  {
  
   int x= 2;
   int y = pow(3,x);
   printf("%d\n",y);
  
   return 0;
  }
  </code></pre>
  
  <p><strong>Terminal:</strong></p>
  
  <pre><code>avinash@titanic:~/Desktop/DSF$ gcc power.c -o power
  /tmp/ccTJ7vAH.o: In function `main':
  
  power.c:(.text+0x25): undefined reference to `pow'
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>If I replace x by 2 then it gets executed in an expected way. Doesn't pow function accepts variables as it's parameters?</p>
  
  <p>Note: I have included stdio.h and math.h in the source file.</p>