C++;can';即使使用-std=c++;11 macOSX 我试图在我的Mac上使用C++ 2011正则表达式。我正在使用Eclipse进行编码,只是稍微涉足了从终端进行编译

C++;can';即使使用-std=c++;11 macOSX 我试图在我的Mac上使用C++ 2011正则表达式。我正在使用Eclipse进行编码,只是稍微涉足了从终端进行编译,c++,regex,include-path,C++,Regex,Include Path,这就是我试图编译代码时发生的情况: $ c++ -std=c++11 -o a *.cpp scanner.cpp:11:10: fatal error: 'regex' file not found #include <regex> // to use this need to use -std=c++11 flag in compiler ^ 1 error generated. 现在,我在我的计算机上找到了我希望包含在项目中的文件 “usr/lib/c++

这就是我试图编译代码时发生的情况:

$ c++ -std=c++11 -o a *.cpp
scanner.cpp:11:10: fatal error: 'regex' file not found
#include <regex>  // to use this need to use -std=c++11 flag in compiler
         ^
1 error generated.
现在,我在我的计算机上找到了我希望包含在项目中的文件 “usr/lib/c++/v1/regex”。但这不在eclipse中的包含文件中,我不知道如何让我的编译器找到它

如果这是我需要做的工作,如何将其添加到include路径中

更新:

尝试

$ c++ -I/usr/lib/c++/v1 -o a *.cpp
这导致了错误

Undefined symbols for architecture x86_64:
遵循似乎是对代码中每一行的引用,例如

  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::compare(char const*) const", referenced from:
      std::__1::basic_regex<char, std::__1::regex_traits<char> >::__start_matching_list(bool) in scanner-LSmxM4.o
“std::\uu 1::基本字符串::比较(char const*)const”,引用自:
scanner-LSmxM4.o中的std::_1::basic_regex::u start_matching_list(bool)

除了
-std=c++11
之外,还要添加
-stdlib=libc++
。libc++是支持C++11的标准库实现。默认情况下,它使用不支持C++11的libstdc++。整个命令应该如下所示:

c++ -std=c++11 -stdlib=libc++ -o output source.cpp
c++ -std=c++11 -stdlib=libc++ -o output source.cpp