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:
bool r_parser::parseMake(string name, string command, string type, string val)
{
regex regName("^\\w+$");
if(std::regex_match(name, regName) == true)
{
cout << "We have a match!" << endl;
}
return false;
}
And here are the errors I am getting:
'undefined reference to std::basic_regex<char, std::regex_traits<char> >::_M_compile()'
'undefined reference to bool std::regex_match<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<std::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, char, std::regex_traits<char> >(__gnu_cxx::__normal_iterator<char const*, std::string>, __gnu_cxx::__normal_iterator<char const*, std::string>, std::match_results<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<std::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > > >&, std::basic_regex<char, std::regex_traits<char> > const&, std::bitset<11u>)'
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.
Thanks for your time.
EDIT: I forgot to mention I have:
#include <regex>
#include <string>
#include <iostream>
using namespace std;
in my header file.
#inlcude <regex>. It's also missing#inlcude <string>,#inlcude <iostream>, andusing namespace std, all of which are needed for that function to compile.