title: What is wrong with this usage of boost regex library?
body: <p>Here is the code;</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;boost/regex.hpp&gt;
  
  using boost::regex;
  using boost::regex_match;
  
  int main(int argc, char **argv) {
      std::string input;
      regex gdreg(R"(g[a-z]+d)");
      while(true)
      {
          std::cout &lt;&lt; "Give me a word: ";
          std::cin &gt;&gt; input;
          if(input == "q") {
              break;
          }
          if(regex_match(input, gdreg))
              std::cout &lt;&lt; "It's a GD word!" &lt;&lt; std::endl;
          else
              std::cout &lt;&lt; "Nooooooo!" &lt;&lt; std::endl;
      }
  }
  </code></pre>
  
  <p>Here is the error msg:</p>
  
  <pre><code>g++ x.cpp -std=c++11 -o x
  /tmp/ccJ7zdHo.o: In function `bool boost::regex_match&lt;__gnu_cxx::__normal_iterator&lt;char const*, std::string&gt;, std::allocator&lt;boost::sub_match&lt;__gnu_cxx::__normal_iterator&lt;char const*, std::string&gt; &gt; &gt;, char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;(__gnu_cxx::__normal_iterator&lt;char const*, std::string&gt;, __gnu_cxx::__normal_iterator&lt;char const*, std::string&gt;, boost::match_results&lt;__gnu_cxx::__normal_iterator&lt;char const*, std::string&gt;, std::allocator&lt;boost::sub_match&lt;__gnu_cxx::__normal_iterator&lt;char const*, std::string&gt; &gt; &gt; &gt;&amp;, boost::basic_regex&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt; const&amp;, boost::regex_constants::_match_flags)':
  x.cpp:(.text._ZN5boost11regex_matchIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS5_EEEcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEbT_SD_RNS_13match_resultsISD_T0_EERKNS_11basic_regexIT1_T2_EENS_15regex_constants12_match_flagsE[_ZN5boost11regex_matchIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS5_EEEcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEbT_SD_RNS_13match_resultsISD_T0_EERKNS_11basic_regexIT1_T2_EENS_15regex_constants12_match_flagsE]+0x77): undefined reference to `boost::re_detail::perl_matcher&lt;__gnu_cxx::__normal_iterator&lt;char const*, std::string&gt;, std::allocator&lt;boost::sub_match&lt;__gnu_cxx::__normal_iterator&lt;char const*, std::string&gt; &gt; &gt;, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;::match()'
  /tmp/ccJ7zdHo.o: In function `boost::basic_regex&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;::assign(char const*, char const*, unsigned int)':
  x.cpp:(.text._ZN5boost11basic_regexIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE6assignEPKcS7_j[_ZN5boost11basic_regexIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE6assignEPKcS7_j]+0x2a): undefined reference to `boost::basic_regex&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;::do_assign(char const*, char const*, unsigned int)'
  /tmp/ccJ7zdHo.o: In function `boost::re_detail::perl_matcher&lt;__gnu_cxx::__normal_iterator&lt;char const*, std::string&gt;, std::allocator&lt;boost::sub_match&lt;__gnu_cxx::__normal_iterator&lt;char const*, std::string&gt; &gt; &gt;, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;::perl_matcher(__gnu_cxx::__normal_iterator&lt;char const*, std::string&gt;, __gnu_cxx::__normal_iterator&lt;char const*, std::string&gt;, boost::match_results&lt;__gnu_cxx::__normal_iterator&lt;char const*, std::string&gt;, std::allocator&lt;boost::sub_match&lt;__gnu_cxx::__normal_iterator&lt;char const*, std::string&gt; &gt; &gt; &gt;&amp;, boost::basic_regex&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt; const&amp;, boost::regex_constants::_match_flags, __gnu_cxx::__normal_iterator&lt;char const*, std::string&gt;)':
  x.cpp:(.text._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEC2ES6_S6_RNS_13match_resultsIS6_S9_EERKNS_11basic_regexIcSD_EENS_15regex_constants12_match_flagsES6_[_ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEC5ES6_S6_RNS_13match_resultsIS6_S9_EERKNS_11basic_regexIcSD_EENS_15regex_constants12_match_flagsES6_]+0x10b): undefined reference to `boost::re_detail::perl_matcher&lt;__gnu_cxx::__normal_iterator&lt;char const*, std::string&gt;, std::allocator&lt;boost::sub_match&lt;__gnu_cxx::__normal_iterator&lt;char const*, std::string&gt; &gt; &gt;, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;::construct_init(boost::basic_regex&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt; const&amp;, boost::regex_constants::_match_flags)'
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>Not using raw string does not solve the problem.</p>