码迷,mamicode.com
首页 > 系统相关 > 详细

Linux编译安装boost-1_57

时间:2015-01-28 17:42:40      阅读:1325      评论:0      收藏:0      [点我收藏+]

标签:

1 unzip boost_1_57_0.zip
2 ./bootstrap.sh
3 ./b2 toolset=gcc cxxflags="-std=c++11" install
4 find / -name libboost*.a

 

/usr/local/lib目录下

头文件在

/usr/local/include/boost目录下

install 后面可以加参数--prefix=/usr

 

测试:
test.cpp

 1 #include <boost/lexical_cast.hpp>
 2 #include <iostream>
 3 int main()
 4 {
 5     using boost::lexical_cast;
 6     int a = lexical_cast<int>("123");
 7     double b = lexical_cast<double>("123.12");
 8     std::cout<<a<<std::endl;
 9     std::cout<<b<<std::endl;
10     return 0;
11 }

 

test2.cpp

#include <iostream>
#include <cassert>
#include <string>
#include <boost/regex.hpp>
using namespace std;
using namespace boost;
int main()
{
        const char *szReg = "(\\w+)://((\\w+\\.)*\\w+)((/\\w*)*)(/\\w+\\.\\w+)?";
        const char *szStr = "http://www.cppprog.com/2009/0112/48.html";

        boost::regex reg( szReg );
        bool r=boost::regex_match( szStr , reg);

        assert(r); //是否匹配


        return 0;
}

 编译:

g++ boost.cpp -o boost /usr/local/lib/libboost_regex.a -I /usr/local/include

 

 

 

Linux编译安装boost-1_57

标签:

原文地址:http://www.cnblogs.com/redhat520/p/4256327.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!