title: Linker error : ld: symbol(s) not found for architecture x86_64
body: <p>I'm trying to compile the following bit of code using the terminal on my Mac. The code is written in Sublime Text. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;vector&gt; 
  #include &lt;unordered_map&gt;
  #include &lt;iomanip&gt;
  #include &lt;cmath&gt;
  #include &lt;string&gt; 
  #include &lt;locale&gt; 
  #include &lt;cstdlib&gt;
  
  using namespace std;
  
  void parse(string s, vector&lt;string&gt; q);
  
  int main(int argc, char* argv[])
  {
  
      cout &lt;&lt; argv[1] &lt;&lt; endl;
      cout &lt;&lt; argv[2] &lt;&lt; endl;
      cout &lt;&lt; argv[3] &lt;&lt; endl;
      cout &lt;&lt; argv[4] &lt;&lt; endl;
  
      int h = stoi(argv[1]);
      int k, c;
      string query;
      vector&lt;string&gt; query_words;
      if(!strcmp(argv[2], "-k"))
      {
          k = stod(argv[3]);
      }
  
      if(!strcmp(argv[2], "-c"))
      {
          c = stod(argv[3]);
      }
  
  
      query = argv[4];
      parse(query, query_words);
  
      return 0;
  }
  
  
  void parse(string s, vector&lt;string&gt; &amp;q)
  {
  
      string x;
      for(size_t i = 0; i &lt; s.length(); i++)
      {
          string temp;
          if(s[i] == '_')
          {
              s[i] = ' ';
          }
  
          if(!isalnum(s[i]) &amp;&amp; s[i] != ' ')
          {
              temp = s.substr(i+1, s.length() - i-1); 
              x = s.substr(0, i) +  temp;
              s = x;
              i--;
          }
      }
  
      int start_subString = 0;
      for(size_t i = 0; i &lt; s.length(); i++)
      {
          if(s[i] == ' ')
          {
              string temp = s.substr(start_subString, i - start_subString);
              start_subString = i+1;
              q.push_back(temp);
  
          }
  
          if(i+1 == s.length())
          {
              string temp = s.substr(start_subString, i + 1 - start_subString);
              q.push_back(temp);
  
          }
      }
  
  
  }
  </code></pre>
  
  <p>I attempt to compile using the following line:
  </p>
  
  <pre class="lang-none prettyprint-override"><code>g++ -std=c++11 hits.cpp -o hits
  </code></pre>
  
  <p>and this results in the following error:</p>
  
  <pre class="lang-none prettyprint-override"><code>Undefined symbols for architecture x86_64:
    "parse(std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;, std::__1::vector&lt;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;, std::__1::allocator&lt;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; &gt; &gt;)", referenced from:
        _main in hits-d8b25c.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>