Ubuntu 14.04 编译安装 boost 1.58

简介

Boost is a set of libraries for the C++ programming language that provide support for tasks and structures such as linear algebra, pseudorandom number generation, multithreading, image processing,regular expressions, and unit testing. It contains over eighty individual libraries.(From Wiki)

安装步骤

下载地址:http://sourceforge.net/projects/boost/files/boost/1.58.0/boost_1_58_0.tar.bz2/download

编译前所需的库

1 sudo apt-get install mpi-default-dev # mpi related
2 sudo apt-get install libicu-dev # regular expresion related
3 sudo apt-get install python-dev # python dev related
4 sudo apt-get install libbz2-dev # I don't know

编译安装boost

1 tar xf boost_1_58_0.tar.gz
2 cd boost_1_58_0/
3 ./bootstrap.sh
4 ./b2 -a -sHAVE_ICU=1 # the parameter means that it support icu or unicode
5 sudo ./b2 install

测试boost是否安装成功

c++代码(testBoost.cpp)

1 #include <iostream>
 2 #include <boost/timer.hpp>
 3 
 4 using namespace boost;
 5 
 6 int main()
 7 {
 8         timer t;
 9         std::cout << "max timespan:" << t.elapsed_max() / 3600 << "h" << std::endl;
10         std::cout << "min timespan:" << t.elapsed_min() << "s" << std::endl;
11 
12         std::cout << "now itme elapsed:" << t.elapsed() << "s" << std::endl;
13 
14         return EXIT_SUCCESS;
15 }

编译指令

1 g++ testBoost.cpp -lboost_system -lboost_filesystem -o testBoost

运行结果

Ubuntu 14.04 编译安装 boost 1.58
原文链接: https://www.cnblogs.com/loadofleaf/p/5668109.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/236931

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月13日 下午5:13
下一篇 2023年2月13日 下午5:13

相关推荐