在Arch Linux中使用c++Boost正则表达式库
Using the c++ Boost regex libraries in Arch Linux
我在构建一个简单的c++程序以测试boost库中的regex时遇到了问题。我遇到的问题发生在链接阶段,我不知道如何独自修复错误。
在使用正则表达式的.cpp程序中,我使用了以下include行。
#include <boost/regex.hpp>
我不知道该用什么命令来用g++构建程序。我尝试使用以下命令行(及其变体)来构建程序。
g++ -I/usr/include/regex -L/usr/lib -llibboost_regex main.cpp -o regex_test
其他可能相关的信息:
Operating system: Arch linux
g++ version: 4.6.2 20120120 (prerelease)
如有任何帮助,我们将不胜感激。
假设您已经安装了带有boost
和boost-libs
包的Boost,
- 标头
<boost/regex.hpp>
应存在于/usr/include/boost/regex.hpp
中。您不需要使用任何-I
标志,因为默认情况下应该包括/usr/include
- 您也不需要
-L
标志,因为链接时默认情况下也应包括/usr/lib
- 当使用
-l
标志与库libfoo.so
链接时,应删除前导的"lib"部分
因此,命令行应该是:
g++ main.cpp -o regex_test -lboost_regex
相关文章:
- FindPackageHandleStandardArgs.cmake:137 的 CMake 错误(消息):找不到 Boost (缺少:正则表达式)(找到合适的版本"1.72.0",
- 为什么 Boost:正则表达式没有按预期找到所有结果?
- 使用 boost::regex 从目录中获取带有一些正则表达式的文件名称时出现意外输出
- 我的 Boost 正则表达式与任何内容都不匹配
- 使用boost正则表达式时出现shared_ptr错误
- Boost正则表达式:链接时未定义的引用
- 递归匹配与 boost 正则表达式库
- 提高Boost正则表达式的速度或在C++中使用PCRE
- boost正则表达式中的命名捕获/组列表
- 将 C++11 正则表达式与 gcc 4.8.2 一起使用时会出现奇怪的结果(但适用于 Boost 正则表达式)
- 使用boost正则表达式标记文本
- 使用boost正则表达式提取所有以短划线分隔的数字
- Boost正则表达式不替换正则表达式网站上正确替换的表达式
- 在Arch Linux中使用c++Boost正则表达式库
- 将C++Boost正则表达式转换为Python正则表达式
- 使用boost正则表达式解析文本文件
- 搜索/替换boost正则表达式
- Boost正则表达式拆分未命中最后一个单词
- CGI 不适用于 Boost 正则表达式
- 在c++中使用boost正则表达式匹配从字符串转换为整型时出错