Good morning!
I have problem with regular expressions in C++11. I have Ubuntu Light 14.04 and this version of compiler:
g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
I installed boost today using this three commands.
sudo apt-get install libboost-all-dev
sudo apt-get install aptitude
aptitude search boost
When i compile this simple program:
#include <iostream>
#include <string>
#include <boost/regex.hpp>
using namespace boost;
using namespace std;
int main()
{
string text;
regex pattern( "\\w* to \\w*" );
return 0;
}
using this command:
g++ main.cpp
compiler returns:
/tmp/ccOdFz7f.o: In function `boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::assign(char const*, char const*, unsigned int)':
main.cpp:(.text._ZN5boost11basic_regexIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE6assignEPKcS7_j[_ZN5boost11basic_regexIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE6assignEPKcS7_j]+0x22): undefined reference to `boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::do_assign(char const*, char const*, unsigned int)'
collect2: error: ld returned 1 exit status
I read this topic: linker error in boost regex and used this command:
g++ -I /usr/lib/boost/include -L /usr/lib/boost/lib main.cpp -lboost_regex-mt
but compiler returns:
/usr/bin/ld: cannot find -lboost_regex-mt
collect2: error: ld returned 1 exit status
I also don't have /usr/lib/boost directory!!!
What should i change in this program or do in Ubuntu to use regular expressions from boost?