(newbie) problem using boost::regex on kubuntu 7.10
Hello,
i am new to c++ coding and for practicing i want to rewrite some of my old
perl scripts that use regular expressions in c++. So i installed libboost
for regex version 1.34.1 on my workstation (using a kubuntu package).
Unfortunatley even the most simple program i can think of does not want to
compile:
#include <iostream>
#include <cstdlib>
#include
canx11 wrote: [...]
[...] testapp.o: In function `boost::basic_regex
>::assign(char const*, char const*, unsigned int)': /usr/include/boost/regex/v4/basic_regex.hpp:255: undefined reference to `boost::basic_regex >::do_assign(char const*, char const*, unsigned int)' collect2: ld returned 1 exit status [...] [...] Do i have problem with my libboost installation or just a simple syntax error here?
Are you linking your program with the regex library? -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim - grafikrobot/yahoo
canx11 wrote:
Hello,
i am new to c++ coding and for practicing i want to rewrite some of my old perl scripts that use regular expressions in c++. So i installed libboost for regex version 1.34.1 on my workstation (using a kubuntu package).
Unfortunatley even the most simple program i can think of does not want to compile:
#include <iostream> #include <cstdlib> #include
using namespace boost; using namespace std; int main(int argc, char *argv[]) { boost::regex(".*"); cout << "test\n"; return 0; }
...giving me:
[...] testapp.o: In function `boost::basic_regex
>::assign(char const*, char const*, unsigned int)': /usr/include/boost/regex/v4/basic_regex.hpp:255: undefined reference to `boost::basic_regex >::do_assign(char const*, char const*, unsigned int)' collect2: ld returned 1 exit status [...] Anyhow if i am doing
int main(int argc, char *argv[]) { boost::regex(); cout << "test\n"; return 0; }
withouth passing a regex condition it compiles successful...Yes i know this short programm does not give any meaningful functionality but i just want to demonstrate that the intialization of the basic_regex fails on my machine.
Do i have problem with my libboost installation or just a simple syntax error here?
regards
Jan _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
link with -lboost_regex-gcc41-1_34_1 -- Jin Sun MS-CS Michigan Technological University 1400 Townsend Dr. Houghton, MI-49931. Phone #: (906) 370 2261(H) (906) 487 4305(O) http://www.cs.mtu.edu/~jinsun
On Friday 23 November 2007, Jin Sun wrote:
link with -lboost_regex-gcc41-1_34_1
-- Jin Sun
Hello Jin, thank you for the good tip...that closed my issue. I first tried the flag with c++ compiler from command line which succeeded and search around in the project options of kdevelop where I then set the linker flags as well and then it also worked from the ide. Now i was able to add the regex functionality to my header file where i have a method that checks with boost::regex_match wether a passed string argument is a valid IP address and it works fine. Here is the short snippet: bool IpValid(string strIpAddress){ string strPattern = "\\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]| 2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25 [0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b"; regex regExpression(strPattern); return regex_match(strIpAddress,regExpression); }; Best regards, Jan
participants (3)
-
canx11
-
Jin Sun
-
Rene Rivera