g++没有从regex系统头文件中找到符号
G++ not finding symbols from regex system header
我试图在我的c++项目中使用GNU C库regex功能,特别是我试图使用regex_t regcomp, regexec, regfree函数。在编译时,我得到这些符号未定义的错误:
me> g++ -I/me/myheaders/ -c RootGenerator.cpp -o RootGenerator.o -std=gnu++0x -Wall
RootGenerator.cpp: In function ‘std::string findFirstFileInCurrentDirectory(std::string)’:
RootGenerator.cpp:1072: error: ‘regex_t’ was not declared in this scope
RootGenerator.cpp:1072: error: expected ‘;’ before ‘re’
RootGenerator.cpp:1073: error: ‘re’ was not declared in this scope
RootGenerator.cpp:1073: error: ‘REG_EXTENDED’ was not declared in this scope
RootGenerator.cpp:1073: error: ‘REG_NOSUB’ was not declared in this scope
RootGenerator.cpp:1073: error: ‘regcomp’ was not declared in this scope
RootGenerator.cpp:1074: error: expected ‘;’ before ‘int’
RootGenerator.cpp:1084: error: ‘status’ was not declared in this scope
RootGenerator.cpp:1084: error: ‘regexec’ was not declared in this scope
RootGenerator.cpp:1092: error: ‘REG_NOMATCH’ was not declared in this scope
RootGenerator.cpp:1108: error: ‘regfree’ was not declared in this scope
我意识到regex头文件是TR1实现,因此对于我的GCC版本来说是实验性的。我根据第一次尝试编译时收到的编译器警告添加了-std=gnu++0x
编译器选项,但这似乎并没有解决问题。这是系统不识别和添加路径到"实验"头的问题吗?是否有需要指定的附加包含路径或编译器选项?
作为额外的注意事项,我注意到在Eclipse/CDT中,在Project Explorer视图中的"includes"选项卡下,它显示了系统头路径的列表。它列出了/user/include/c++/4.4.4 path选项卡下的许多头文件,但它没有列出regex头文件。
发现问题:
#include <regex>
应该#include <regex.h>
regex.h
头是正则表达式的GNU C库实现,包含我试图在我的源代码中使用的函数。regex
头是TR1(和不完整)正则表达式的实现。所以@Oli,我毕竟没有引用相关的标题!
相关文章:
- 使用gcc从静态链接的文件中查找可选符号
- 检测 COFF 对象文件中C++内联符号
- 使用 fopen 打开 .pak 文件并使该文件应用于 const 无符号字符* (C++)
- 如何从二进制文件中的给定符号中获取调用程序图
- 如何将 UTF-8 文本从文件转换为某个可以迭代的容器,并检查每个符号是否为C++字母数字?
- CMake 生成的 MSVC 项目找不到符号,即使为其相关 dll 正确生成了 lib 文件也是如此
- 错误:当我从"WinDbg"打开可执行文件时,找不到符号文件。默认导出 ntdll 的符号.dll
- 可以在 cpp 文件中C++定义为特殊符号的变量β
- 尝试将字符串从文件读取到无符号字符向量中
- C++和带有国家符号的文件路径(也许用 UTF8 编码)
- OSX clang++:用于 cpp 文件中显式实例化模板的体系结构x86_64的未定义符号
- 生成文件:体系结构x86_64的未定义符号
- 标头保护文件中结构的重复符号
- 使用共享库编译可执行文件时仅链接所需的符号
- C++ - 将任何文件的字节读取到无符号字符数组中
- 体系结构x86_64的未定义符号:c++/ h 文件和 cpp 文件
- c/c 的文件/符号依赖图形可视化
- 计算 c# 中二进制文件符号的频率不起作用,但适用于等效的 c++ 代码
- Visual c++资源文件符号
- 创建一个只包含所有目标文件符号的文件时应该使用什么命令?