Boost logo

Boost Users :

Subject: [Boost-users] Boost.Regex Can't compile / link programs..
From: John Mc Murray (john_at_[hidden])
Date: 2010-05-19 10:39:44


Hello all,

I am trying to evaluate boost, I've heard some good things about it...

I've managed to set it up mostly successfully.

On boosts page:
http://www.boost.org/doc/libs/1_43_0/more/getting_started/windows.html#get-boost

I've managed to compile the first program which does not use any
separately compiled libs..

When I try to compile the second program which uses the regex lib, I get
a link error...

There are many link errors, but I am only posting the first one from
gcc's output:

C:\DOCUME~1\John\LOCALS~1\Temp\ccgmT8rw.o:reg.cpp:(.text$_ZN5boost9re_detail27cpp_regex_traits_char_layerIcEC2ERKNS0_21cpp_regex_traits_baseIcEE[boost::re_detail::cpp_regex_traits_char_layer<char>::cpp_regex_traits_char_layer(boost::re_detail::cpp_regex_traits_base<char>
const&)]+0x55): undefined reference to
`boost::re_detail::cpp_regex_traits_char_layer<char>::init()'

When I comment out the 3 lines in the code snippet below (marked with
//comment out), but I leave the one line boost::smatch matches; it does
compile..

Does that mean that I have Regex installed correctly, but I am maybe
missing a lib when I try to compile

Here is how I'm trying to compile:

g++ -I ../boost_1_43_0 -L ../boost_1_43_0/stage/lib -luser32 -lpthread
-lboost_program_options-mgw44-mt-1_43 -lboost_regex-mgw44-mt-1_43
-lboost_thread-mgw44-mt-1_43 -o r reg.cpp

Maybe I don't need to include all those libs, but I keep adding libs,
hoping that something will work

Also, if I remove the args to boost::regex,

boost::regex pat("^Subject: (Re: |Aw: )*(.*)");

to

boost::regex pat();

then the software compiles with no warnings...

Anyone know what's up here? Oh, I'm using this on windows (MinGW - g++)
now, but once its working here I'll need to redo it all on Linux (Mandriva).

Thanks...

John

/***************************************************************************/

#include <boost/regex.hpp>
#include <iostream>
#include <string>

int main()
{
    std::string line;
    boost::regex pat("^Subject: (Re: |Aw: )*(.*)"); //comment out

    while (std::cin)
    {
        std::getline(std::cin, line);
        boost::smatch matches;
        if (boost::regex_match(line, matches, pat)) //comment out
            std::cout << matches[2] << std::endl; // comment out
    }
}

/***************************************************************************/

-- 
John Mc Murray
john_at_[hidden]
www.softsmart.co.za
Cell: 083 784 6313
Tel: 011 083 7085
Fax: 086 650 5573
Make money from your website or blog. Join our affiliate program now! www.softsmart.co.za/affiliates

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