title: Undefined reference to pow( ) in C, despite including math.h
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/10167714/what-is-undefined-reference-to-pow">what is &#39;undefined reference to `pow&#39;&#39;</a>  </p>
  </blockquote>
  
  
  
  <p>I'm having a bit of an issue with a simple piece of coursework for uni that's really puzzling me.</p>
  
  <p>Essentially, I've to write a program that, amongst other things, calculates the volume of a sphere from a given radius. I thought I'd use the <code>pow()</code> function rather than simply using <code>r*r*r</code>, for extra Brownie points, but the compiler keeps giving me the following error:</p>
  
  <blockquote>
    <p>undefined reference to 'pow'
    collect2: error: ld returned 1 exit status</p>
  </blockquote>
  
  <p>My code looks like the following:</p>
  
  <pre><code>#include &lt;math.h&gt;
  
  #define PI 3.14159265 //defines the value of PI
  
  /* Declare the functions */
  double volumeFromRadius(double radius);
  
  /* Calculate the volume of a sphere from a given radius */
  double volumeFromRadius(double radius) {
      return (4.0/3.0) * PI * pow(radius,3.0f);
  }
  </code></pre>
  
  <p>and I'm compiling with the command <code>gcc -o sphere sphere.c</code></p>
  
  <p>This compiles and runs fine in code::blocks on the Windows machines at uni, but on my Fedora 17 at home the command line compiler refuses to run. Any thoughts would be gratefully appreciated!</p>
  
  <p>Blessings,
  Ian</p>