compile error for regex

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

    I run into some errors when compiling a piece of code using regex.
Who can help me on this?

The detailed information is:
linux-roger:/home/lishli/cpp # uname -a
Linux linux-roger 2.6.16.60-0.54.5-default #1 Fri Sep 4 01:28:03 UTC
2009 i686 i686 i386 GNU/Linux
linux-roger:/home/lishli/cpp # gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/lishli/gcc/libexec/gcc/i686-pc-linux-gnu/4.5.1/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ./configure --prefix=/home/lishli/gcc
--enable-languages=c,c++ --enable-threads --enable-tls
Thread model: posix
gcc version 4.5.1 (GCC)

linux-roger:/home/lishli/cpp/regex# cat 1.cpp
#include <iostream>
#include <regex>

int main () {
  const char* text = "Hello World";
  const char* reg_exp = " ";
  std::regex rgx(reg_exp);
  if (std::regex_match(text, rgx)) {
    std::cout << "space is in the text!" << std::endl;
  }

linux-roger:/home/lishli/cpp/regex # g++ -std=c++0x -g -o 1 1.cpp
/tmp/ccULPeih.o: In function `basic_regex':
/home/lishli/gcc/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/tr1_impl/regex:771:
undefined reference to `std::basic_regex<char, std::regex_traits<char>
>::_M_compile()'
/tmp/ccULPeih.o: In function `bool std::regex_match<char const*, char,
std::regex_traits<char> >(char const*, char const*,
std::basic_regex<char, std::regex_traits<char> > const&,
std::bitset<11u>)':
/home/lishli/gcc/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/tr1_impl/regex:2144:
undefined reference to `bool std::regex_match<char const*,
std::allocator<std::sub_match<char const*> >, char,
std::regex_traits<char> >(char const*, char const*,
std::match_results<char const*, std::allocator<std::sub_match<char
const*> > >&, std::basic_regex<char, std::regex_traits<char> > const&,
std::bitset<11u>)'
collect2: ld returned 1 exit status


}


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux