title: Use C function in C++ program; "multiply-defined" error
body: <p>I am trying to use <a href="http://tartarus.org/~martin/PorterStemmer/c.txt" rel="nofollow noreferrer">this code for the Porter stemming algorithm</a> in a C++ program I've already written. I followed the instructions near the end of the file for using the code as a separate module. I created a file, stem.c, that ends after the definition and has</p>
  
  <pre><code>extern int stem(char * p, int i, int j) ...
  </code></pre>
  
  <p>It worked fine in Xcode but it does not work for me on Unix with gcc 4.1.1--strange because usually I have no problem moving between the two. I get the error</p>
  
  <blockquote>
    <p>ld: fatal: symbol `stem(char*, int, int)' is multiply-defined:
            (file /var/tmp//ccrWWlnb.o type=FUNC; file /var/tmp//cc6rUXka.o type=FUNC);
    ld: fatal: File processing errors. No output written to cluster</p>
  </blockquote>
  
  <p>I've looked online and it seems like there are many things I could have wrong, but I'm not sure what combination of a header file, extern "C", etc. would work.</p>