【发布时间】:2023-03-18 00:56:01
【问题描述】:
所以我尝试在我的 Mac 上在家中使用 c++ 2011 正则表达式。我正在使用 Eclipse 进行编码,稍微涉足从终端编译。
这是我尝试编译代码时发生的情况:
$ 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.
无论我是否使用 -std=c++11 标志都会发生这种情况。
这是我的 c++ -v:
$ c++ -v
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.4.0
Thread model: posix
现在我在我的计算机上找到了我想要包含在我的项目中的文件 “usr/lib/c++/v1/正则表达式”。但这不在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
【问题讨论】:
标签: c++ regex include-path