分享

Ubuntu16.04安装boost1.71.0库

 netouch 2023-09-13

Ubuntu16.04安装boost1.71.0库

fun binary 于 2019-11-04 15:32:25 发布 3795 收藏 9
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

下载boost

官网:
https://www./
1.71.0下载地址:
https://dl./boostorg/release/1.71.0/source/

解压下载的文件

tar -zxvf boost_1_71_0.tar.gz

进入解压的文件路径

cd boost_1_71_0

执行命令

sudo ./bootstrap.sh

在执行下面的命令,这样头文件就被默认安装在/usr/local/include头文件下,库文件就被默认安装在/usr/local/lib下

sudo ./b2 install

配置环境变量

vim /etc/ld.so.conf
添加/usr/local/lib
执行ldconfig

测试代码

#include <iostream>
#include <boost/regex.hpp>
#include <boost/algorithm/string.hpp>
using namespace std;
 
int main(){
    string str = "data-num=\"1056\"";
    boost::regex reg("\\d{1,6}");//{1,6}表示\d重复1-6次,\d表示匹配整数
    boost::smatch what;
    string::const_iterator begin = str.begin();
    string::const_iterator end = str.end();
 
    boost::regex_search(begin,end,what,reg);
    string result(what[0].first,what[0].second);
    cout << result << endl;
    return 0;
}

编译

g++ -o test test.cc -std=c++11  -I /usr/local/include -L /usr/local/lib  -lboost_regex

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多