编译std :: regex_iterator与gcc [英] Compile std::regex_iterator with gcc
本文介绍了编译std :: regex_iterator与gcc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以使用 g ++ -c test.cpp -std = c ++ 0x 创建.o文件,但是无法链接,会出现下列错误:
I can create .o file with g++ -c test.cpp -std=c++0x, but cant link it, got next errors:
test.cpp:(.text+0xe5): undefined reference to `std::regex_iterator<char const*, char, std::regex_traits<char> >::regex_iterator(char const*, char const*, std::basic_regex<char, std::regex_traits<char> > const&, std::bitset<11u>)'
test.cpp:(.text+0xf1): undefined reference to `std::regex_iterator<char const*, char, std::regex_traits<char> >::regex_iterator()'
代码:
#include <regex>
#include <iostream>
#include <string.h>
typedef std::regex_iterator<const char *> Myiter;
int main()
{
const char *pat = "axayaz";
Myiter::regex_type rx("a");
Myiter next(pat, pat + strlen(pat), rx);
Myiter end;
return (0);
}
推荐答案
GNU C ++标准库支持< regex>
,但不能低于4.9.0版。 (头文件在早期版本中存在,但不可用。)
The GNU C++ standard library supports <regex>
, but not until version 4.9.0. (The headers were present in earlier versions, but were unusable.)
其他编译器不支持它,就我所见。
The other compilers don't support it, as far as I can see.
您可以使用不同的库,如果您使用较旧的GCC。
You can use a different library if you use an older GCC.
这篇关于编译std :: regex_iterator与gcc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文