
mix@openflex.net wrote:
Hi all,
I'm a newbie in c++ and in boost too, but i want to learn ;) I've installed boost via apt and also with "hand-compile" but it doesn't run anyway..
here my code:
-------------------- #include <iostream> #include
using namespace boost; using namespace std;
int main() { const boost::regex e("PING\\s:\\S+"); cmatch match;
if(boost::regex_match("PING :jgWEjg",match,e)) { cout << "PONG :" << match[1]; }
return 0; } --------------------
then i want to compile it with ""g++ main.cc -o test"
This is your problem. The boost regex library is not a header only library like some of the others, so you must link against it! This is what causes "undefined reference to ____" errors - these are linker errors generated because it dosn't know where to find the implementation of this function. The exact line used will depend on your system. On my windows box using MinGW I'd link against it like so: g++ main.cc -o test -lboost_regex-mgw Note that the -mgw postfix refers to MinGW, so obviously your milage will vary.