Linux编译安装boost-1_57
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
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。