|
Boost Users : |
From: Guan Bin (gb0519_at_[hidden])
Date: 2004-04-30 00:58:38
Hi,
the simple code is below:
____________________________________________________________________
#include <iostream>
#include <string>
#include "boost/regex.hpp"
using namespace boost;
regex expression("this is ([[:digit:]]*)");
int main(int argc, char* argv[])
{
while (true)
{
char buf[1000];
memset(buf, 0, 1000);
std::cin.getline(buf, 1000);
std::string str(buf);
cmatch match;
if (!regex_match(str, match, expression))
{
std::cout<<"Don't match"<<std::endl;
continue;
}
for (int i = 0; i < match.size(); i++)
{
std::string msg;
msg.assign(match[i].first, match[i].second);
std::cout<<msg<<std::endl;
}
}
return 0;
}
____________________________________________________________________________________
the makefile is below
------------------------------------------------------
INCLUDE_DIR = /unzipped/boost_1_31_0/ -I/usr/local/include/stlport/
#INCLUDE_DIR = /unzipped/boost_1_31_0/
LIB_DIR = /unzipped/boost_1_31_0/libs/regex/build/gcc/ -L/usr/local/lib/
#LIB_DIR = /unzipped/boost_1_31_0/libs/regex/build/gcc/
LINK = boost_regex-gcc-1_31 -lstlport_gcc
#LINK = boost_regex-gcc-1_31
FLG = -Wall
all : regex_sample.o
g++ regex_sample.o -L$(LIB_DIR) $(FLG) -l$(LINK) -o sample
%.o : %.cpp
g++ -I$(INCLUDE_DIR) -L$(LIB_DIR) $(FLG) -l$(LINK) -c $<
--------------------------------------------------------------
and the error information is :
------------------------------------------------------------
[root_at_guanbin regex]# make
g++ -I/unzipped/boost_1_31_0/ -I/usr/local/include/stlport/ -L/unzipped/boost_1_31_0/libs/regex/build/gcc/ -L/usr/local/lib/ -Wall -lboost_regex-gcc-1_31 -lstlport_gcc -c regex_sample.cpp
regex_sample.cpp: In function `int main(int, char**)':
regex_sample.cpp:37: warning: comparison between signed and unsigned integer
expressions
g++: -lboost_regex-gcc-1_31: linker input file unused because linking not done
g++: -lstlport_gcc: linker input file unused because linking not done
g++ regex_sample.o -L/unzipped/boost_1_31_0/libs/regex/build/gcc/ -L/usr/local/lib/ -Wall -lboost_regex-gcc-1_31 -lstlport_gcc -o sample
regex_sample.o(.gnu.linkonce.t._ZN5boost9re_detail12perl_matcherIPKcN4_STL9allocatorINS_9sub_matchIS3_EEEENS_12regex_traitsIcEENS5_IcEEEC1ES3_S3_RNS_13match_resultsIS3_S8_EERKNS_14reg_expressionIcSA_SB_EENS_15regex_constants12_match_flagsE+0x51): In function `boost::re_detail::perl_matcher<char const*, _STL::allocator<boost::sub_match<char const*> >, boost::regex_traits<char>, _STL::allocator<char> >::perl_matcher[in-charge](char const*, char const*, boost::match_results<char const*, _STL::allocator<boost::sub_match<char const*> > >&, boost::reg_expression<char, boost::regex_traits<char>, _STL::allocator<char> > const&, boost::regex_constants::_match_flags)':
: undefined reference to `boost::reg_expression<char, boost::regex_traits<char>, _STL::allocator<char> >::get_traits() const'
regex_sample.o(.gnu.linkonce.t._ZN5boost9re_detail12perl_matcherIPKcN4_STL9allocatorINS_9sub_matchIS3_EEEENS_12regex_traitsIcEENS5_IcEEEC1ES3_S3_RNS_13match_resultsIS3_S8_EERKNS_14reg_expressionIcSA_SB_EENS_15regex_constants12_match_flagsE+0x8a): In function `boost::re_detail::perl_matcher<char const*, _STL::allocator<boost::sub_match<char const*> >, boost::regex_traits<char>, _STL::allocator<char> >::perl_matcher[in-charge](char const*, char const*, boost::match_results<char const*, _STL::allocator<boost::sub_match<char const*> > >&, boost::reg_expression<char, boost::regex_traits<char>, _STL::allocator<char> > const&, boost::regex_constants::_match_flags)':
: undefined reference to `boost::reg_expression<char, boost::regex_traits<char>, _STL::allocator<char> >::empty() const'
regex_sample.o(.gnu.linkonce.t._ZN5boost9re_detail12perl_matcherIPKcN4_STL9allocatorINS_9sub_matchIS3_EEEENS_12regex_traitsIcEENS5_IcEEE24estimate_max_state_countEPNS4_26random_access_iterator_tagE+0x2c): In function `boost::re_detail::perl_matcher<char const*, _STL::allocator<boost::sub_match<char const*> >, boost::regex_traits<char>, _STL::allocator<char> >::estimate_max_state_count(_STL::random_access_iterator_tag*)':
: undefined reference to `boost::reg_expression<char, boost::regex_traits<char>, _STL::allocator<char> >::size() const'
regex_sample.o(.gnu.linkonce.t._ZN5boost9re_detail12perl_matcherIPKcN4_STL9allocatorINS_9sub_matchIS3_EEEENS_12regex_traitsIcEENS5_IcEEE9match_impEv+0x94): In function `boost::re_detail::perl_matcher<char const*, _STL::allocator<boost::sub_match<char const*> >, boost::regex_traits<char>, _STL::allocator<char> >::match_imp()':
: undefined reference to `boost::reg_expression<char, boost::regex_traits<char>, _STL::allocator<char> >::mark_count() const'
regex_sample.o(.gnu.linkonce.t._ZN5boost9re_detail8access_tIcNS_12regex_traitsIcEEN4_STL9allocatorIcEEE5firstERKNS_14reg_expressionIcS3_S6_EE+0xd): In function `boost::re_detail::access_t<char, boost::regex_traits<char>, _STL::allocator<char> >::first(boost::reg_expression<char, boost::regex_traits<char>, _STL::allocator<char> > const&)':
: undefined reference to `boost::reg_expression<char, boost::regex_traits<char>, _STL::allocator<char> >::first(boost::reg_expression<char, boost::regex_traits<char>, _STL::allocator<char> > const&)'
regex_sample.o(.gnu.linkonce.t._ZN5boost9re_detail11raise_errorINS_12regex_traitsIcEEEEvRKT_j+0x21): In function `void boost::re_detail::raise_error<boost::regex_traits<char> >(boost::regex_traits<char> const&, unsigned)':
: undefined reference to `boost::re_detail::raise_regex_exception(_STL::basic_string<char, _STL::char_traits<char>, _STL::allocator<char> > const&)'
regex_sample.o(.gnu.linkonce.t._ZN5boost9re_detail8access_tIcNS_12regex_traitsIcEEN4_STL9allocatorIcEEE9can_startEcPKhh+0x24): In function `boost::re_detail::access_t<char, boost::regex_traits<char>, _STL::allocator<char> >::can_start(char, unsigned char const*, unsigned char)':
: undefined reference to `boost::reg_expression<char, boost::regex_traits<char>, _STL::allocator<char> >::can_start(char, unsigned char const*, unsigned char, boost::re_detail::_narrow_type const&)'
regex_sample.o(.gnu.linkonce.t._ZN5boost9re_detail16re_is_set_memberIPKccNS_12regex_traitsIcEEN4_STL9allocatorIcEEEET_S9_S9_PKNS0_11re_set_longERKNS_14reg_expressionIT0_T1_T2_EE+0x41): In function `char const* boost::re_detail::re_is_set_member<char const*, char, boost::regex_traits<char>, _STL::allocator<char> >(char const*, char const*, boost::re_detail::re_set_long const*, boost::reg_expression<char, boost::regex_traits<char>, _STL::allocator<char> > const&)':
: undefined reference to `boost::reg_expression<char, boost::regex_traits<char>, _STL::allocator<char> >::get_traits() const'
regex_sample.o(.gnu.linkonce.t._ZN5boost9re_detail16re_is_set_memberIPKccNS_12regex_traitsIcEEN4_STL9allocatorIcEEEET_S9_S9_PKNS0_11re_set_longERKNS_14reg_expressionIT0_T1_T2_EE+0x258): In function `char const* boost::re_detail::re_is_set_member<char const*, char, boost::regex_traits<char>, _STL::allocator<char> >(char const*, char const*, boost::re_detail::re_set_long const*, boost::reg_expression<char, boost::regex_traits<char>, _STL::allocator<char> > const&)':
: undefined reference to `boost::c_regex_traits<char>::transform(_STL::basic_string<char, _STL::char_traits<char>, _STL::allocator<char> >&, _STL::basic_string<char, _STL::char_traits<char>, _STL::allocator<char> > const&)'
regex_sample.o(.gnu.linkonce.t._ZN5boost9re_detail16re_is_set_memberIPKccNS_12regex_traitsIcEEN4_STL9allocatorIcEEEET_S9_S9_PKNS0_11re_set_longERKNS_14reg_expressionIT0_T1_T2_EE+0x34b): In function `char const* boost::re_detail::re_is_set_member<char const*, char, boost::regex_traits<char>, _STL::allocator<char> >(char const*, char const*, boost::re_detail::re_set_long const*, boost::reg_expression<char, boost::regex_traits<char>, _STL::allocator<char> > const&)':
: undefined reference to `boost::c_regex_traits<char>::transform_primary(_STL::basic_string<char, _STL::char_traits<char>, _STL::allocator<char> >&, _STL::basic_string<char, _STL::char_traits<char>, _STL::allocator<char> > const&)'
regex_sample.o(.gnu.linkonce.t._ZN5boost11basic_regexIcNS_12regex_traitsIcEEN4_STL9allocatorIcEEEC1EPKcjRKS5_+0x13): In function `boost::basic_regex<char, boost::regex_traits<char>, _STL::allocator<char> >::basic_regex[in-charge](char const*, unsigned, _STL::allocator<char> const&)':
: undefined reference to `boost::reg_expression<char, boost::regex_traits<char>, _STL::allocator<char> >::reg_expression[not-in-charge](char const*, unsigned, _STL::allocator<char> const&)'
regex_sample.o(.gnu.linkonce.t._ZN5boost11basic_regexIcNS_12regex_traitsIcEEN4_STL9allocatorIcEEED1Ev+0xd): In function `boost::basic_regex<char, boost::regex_traits<char>, _STL::allocator<char> >::~basic_regex [in-charge]()':
: undefined reference to `boost::reg_expression<char, boost::regex_traits<char>, _STL::allocator<char> >::~reg_expression [not-in-charge]()'
collect2: ld returned 1 exit status
make: *** [all] Error 1
-------------------------------------------------------------------------------------
the environment is :
linux redhat 9.0
gcc 3.2.2
boost_1_31_0
stlport_4_6_2
Who can help me? thanks
Guan Bin
gb0519_at_[hidden]
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