title: Undefined reference to second function
body: <p>Have following header (and correspondent cpp) in project:</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;vector&gt;
  
  #ifndef STRINGWORK_H
  #define STRINGWORK_H
  
  using namespace std;
  
  vector&lt;string&gt; split(const string&amp; str, const string &amp;delimiters = " ");
  string trim(string &amp;str);
  
  #endif // STRINGWORK_H
  </code></pre>
  
  <p>Building project returns linker error: </p>
  
  <blockquote>
    <p>file.cpp:21: error: undefined reference to `trim(std::string&amp;)'</p>
  </blockquote>
  
  <p>if I add <code>extern "C"</code> to 2nd function, project builds fine. If I also add <code>extern "C"</code> to first function, get linker error again but for the 1st function:</p>
  
  <blockquote>
    <p>file.cpp:16: error: undefined reference to `split'</p>
  </blockquote>
  
  <p>What is the problem here? How to correctly declare such functions?</p>
  
  <p><a href="https://stackoverflow.com/q/12573816/630169">What is an undefined reference/unresolved external symbol error and how do I fix it?</a> - does not explain things, and does not help as here we have C/C++ mixed code.</p>