TR1 - regex Problem



  • Hallo,

    ich habe ein Linker-Problem mit tr1/regex. Das hier kompiliert nicht:

    #include <tr1/regex>
    #include <cassert>
    
    int main () {
      std::tr1::regex rgx("ello");
      assert(std::tr1::regex_search("Hello World", rgx));
    }
    

    Der Linker sagt:

    make -k 
    g++ -c -pipe -std=c++0x -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o const_try.o const_try.cpp
    /usr/include/c++/4.4/tr1_impl/regex:2255: warning: inline function ‘bool std::tr1::regex_search(_Bi_iter, _Bi_iter, std::tr1::match_results<_Bi_iter, _Allocator>&, const std::tr1::basic_regex<_Ch_type, _Rx_traits>&, std::tr1::regex_constants::match_flag_type) [with _Bi_iter = const char*, _Allocator = std::allocator<std::tr1::sub_match<const char*> >, _Ch_type = char, _Rx_traits = std::tr1::regex_traits<char>]’ used but never defined
    g++ -Wl,-O1 -o const_try const_try.o    -L/usr/lib -lQtGui -lQtCore -lpthread 
    const_try.o: In function `main':
    const_try.cpp:(.text+0xdc): undefined reference to `std::tr1::basic_regex<char, std::tr1::regex_traits<char> >::_M_compile()'
    const_try.cpp:(.text+0x142): undefined reference to `bool std::tr1::regex_search<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&, std::bitset<11u>)'
    collect2: ld returned 1 exit status
    ...
    

    Zuerst dachte ich: Klar, es fehlt die entsprechende Linker-Option auf die Library, aber das kann nicht sein, weil das hier kompiliert :

    #include <tr1/array>
    #include <iostream>
    
    int main () {
      std::tr1::array<int, 5>  a = {{ 1,2,3,4,5 }};
      std::cout << a[3] << std::endl;
    }
    

    Hat jemand eine Idee? LG



  • Ich vermute, die sind in der Tat noch nicht implementiert.
    http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.200x



  • Oh... auf das wäre ich nicht gekommen 😮 Besten Dank, hat wohl ein paar Stunden sinnloses googeln erspart 🙂 Werde halt boost nehmen.
    LG



  • Kannst es ja gleich so typedefen, dass du dann nur noch umschalten musst, wenn der Compiler das unterstützt. 😉



  • Klar, danke ! 🙂


Anmelden zum Antworten