|
Boost Users : |
From: Michael B. Edwin Rickert (panda_at_[hidden])
Date: 2005-07-20 22:33:23
mix_at_[hidden] 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 <boost/regex.hpp>
>
> 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.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net