title: Why do I get clang: error: linker command failed with exit code 1?
body: <p>I am a newbie who is slowly working his way through K&amp;R using Xcode. In the Functions section I entered the code for their example of the power function as follows.</p>
  <pre><code>#include &lt;stdio.h&gt;
  
  int power(int m, int n);
  
  int main()
  {
  int i;
  
  for (i=0; 1&lt;10; ++i)
      printf(&quot;%d %d %d\n&quot;, i, power(2,i), power(-3,i));
  
  return 0;
  }
  </code></pre>
  <p>When I try to run it the following error appears:</p>
  <pre><code>Undefined symbols for architecture x86_64:
    &quot;_power&quot;, referenced from:
        _main in main.o
  ld: symbol(s) not found for architecture x86_64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  </code></pre>
  <p>I have read a lot of the answers to this question but cannot see how it applies to my situation with such a little program.<br />
  Would be grateful for any help.</p>