Boost.Regex Can't compile / link programs..
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-b... 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@softsmart.co.za 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
AMDG John Mc Murray wrote:
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
You need to list libraries /after/ the files that uses them. In Christ, Steven Watanabe
Its taken me two days of absolute frustration, about a gazzillion google queries and several posts to Experts-Exchange.com to finally get some advice that actually works!!!! Thank you so much for this, I can't believe I forgot about his "feature" of gcc.... John Mc Murray john@softsmart.co.za 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 John Maddock wrote:
You need to list libraries /after/ the files that uses them.
Indeed, one of gcc's more interesting quirks.... John. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
John Maddock
-
John Mc Murray
-
Steven Watanabe