我使用以下代码收到链接器错误:

#include <regex>

int main()
{
    std::regex rgx("ello");
    return 0;
}

test.o: In function `basic_regex':
/usr/lib/gcc/i586-redhat-linux/4.4.1/../../../../include/c++/4.4.1/tr1_impl/regex:769: undefined reference to `std::basic_regex<char, std::regex_traits<char> >::_M_compile()'
collect2: ld returned 1 exit status
有帮助吗?

解决方案

来自 gcc-4.4.1 / include / c ++ / 4.4.1 / tr1_impl / regex

template <...>
class basic_regexp {
...
   private:
      /**
       * @brief Compiles a regular expression pattern into a NFA.
       * @todo Implement this function.
       */
      void _M_compile();

我猜它还没准备好。

更新:目前的前沿GCC(SVN @ 153546)似乎尚未实施。

其他提示

您可以从以下位置获得建议状态: http://gcc.gnu。组织/ onlinedocs /的libstdc ++ /手动/ bk01pt01ch01.html#manual.intro.status.standard.tr1

使用正则表达式,你可以安装boost库,他们的tr1已经包含了正则表达式。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top