title: Regex Complilation Errors in c++
body: <p>I am working on a project with someone and we have the exact same code however his code compiles while mine continues to throw an error. Here is my code:</p>
  
  <pre><code>bool r_parser::parseMake(string name, string command, string type, string val)
  {
      regex regName("^\\w+$");
      if(std::regex_match(name, regName) == true)
      {
          cout &lt;&lt; "We have a match!" &lt;&lt; endl;
      }
      return false;
  }
  </code></pre>
  
  <p>And here are the errors I am getting:</p>
  
  <pre><code>'undefined reference to std::basic_regex&lt;char, std::regex_traits&lt;char&gt; &gt;::_M_compile()'
  
  'undefined reference to bool std::regex_match&lt;__gnu_cxx::__normal_iterator&lt;char const*, std::string&gt;, std::allocator&lt;std::sub_match&lt;__gnu_cxx::__normal_iterator&lt;char const*, std::string&gt; &gt; &gt;, char, std::regex_traits&lt;char&gt; &gt;(__gnu_cxx::__normal_iterator&lt;char const*, std::string&gt;, __gnu_cxx::__normal_iterator&lt;char const*, std::string&gt;, std::match_results&lt;__gnu_cxx::__normal_iterator&lt;char const*, std::string&gt;, std::allocator&lt;std::sub_match&lt;__gnu_cxx::__normal_iterator&lt;char const*, std::string&gt; &gt; &gt; &gt;&amp;, std::basic_regex&lt;char, std::regex_traits&lt;char&gt; &gt; const&amp;, std::bitset&lt;11u&gt;)'
  </code></pre>
  
  <p>Since my partner's code compiled and we couldn't find anything different about my code I was wondering if anyone could shed some light on this situation. </p>
  
  <p>Thanks for your time.</p>
  
  <p><strong>EDIT:</strong> I forgot to mention I have:</p>
  
  <pre><code>#include &lt;regex&gt;
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  using namespace std;
  </code></pre>
  
  <p>in my header file.</p>