title: Share function implementation between two files in C
body: <p>I want to share some function implementation between couple of files.<br>
  To be more specific, I want <strong>file1.c</strong>  and <strong>file2.c</strong> to both be able to use the same function (instead of just the copy-paste solution), call it <strong>func()</strong>.<br>
  So what I have is:  </p>
  
  <p>file1:  </p>
  
  <pre><code>#include"shared.h"
  int main() {
      int x=func();
  }
  </code></pre>
  
  <p>file2:  </p>
  
  <pre><code>#include"shared.h"
  int main() {
      int y=func();
  }
  </code></pre>
  
  <p>shared.h:</p>
  
  <pre><code>extern int func();
  </code></pre>
  
  <p>shared.c:</p>
  
  <pre><code>#include"Shared.h"
  int func() {
      // some implementation here
  }
  </code></pre>
  
  <p>When I try to compile it with <code>gcc file1.c</code> I get "undefined reference to 'func()'"...<br>
  How do I make it work?</p>