开发者

libstdc++ - compiling failing because of tr1/regex

开发者 https://www.devze.com 2023-02-05 17:49 出处:网络
I have these packages installed on my OpenSUSE 11.3: i | libstdc++45| Standard shared library for C++| package

I have these packages installed on my OpenSUSE 11.3:

i | libstdc++45       | Standard shared library for C++                 | package
i | libstdc++45-devel | Contains files and libraries for development    | package

But when i'm trying to compile this C++ code:

#include <cstdio>
#include <tr1/regex>

using namespace std;

int main() {
    int test[2];
    const tr1::regex pattern(".*");

    test[0] = 1;

    if (tr1::regex_match("anything", pattern) == false) {
        printf("Pattern does not match.\n");
    }
    return 0;
}

using

g++ -pedantic -g -O1 -o ./main.o ./main.cpp

It outputs this errors:

/tmp/cc0g3GUE.o: In function `basic_regex':
/usr/include/c++/4.5/tr1_impl/regex:771: undefined reference to `std::tr1::basic_regex<char, std::tr1::regex_traits<char> >::_M_compile()'
/tmp/cc0g3GUE.o: In function `bool std::tr1::regex_match<char const*, char,     std::tr1::regex_traits<char> >(char const*, char const*, std::tr1::basic_regex<char, std::tr1::regex_traits<char> > const&, std::bitset<11u>)':
/usr/include/c++/4.5/tr1_impl/regex:2144: undefined reference to `bool std::tr1::regex_match<char const*, std::allocator<std::tr1::sub_match<char const*> >, char,     std::tr1::regex_traits<char> >(char const*, char const*, std::tr1::match_results<char     const*, std::allocator<std::tr1::sub_match<char const*> > >&, std::tr1::basic_regex<char, std::tr1::regex_traits<char> > const&a开发者_运维问答mp;, std::bitset<11u>)'
collect2: ld returned 1 exit status

What packages should i (un)install to make the code work on my PC?


You need to look at the c++0x library support for gcc as I think Regex is not yet completed

http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.200x

0

精彩评论

暂无评论...
验证码 换一张
取 消