首页 > 代码库 > Linux编译安装boost-1_57

Linux编译安装boost-1_57

1 unzip boost_1_57_0.zip2 ./bootstrap.sh3 ./b2 toolset=gcc cxxflags="-std=c++11" install4 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