基本信息
源码名称:boost_1_55_0.tar.gz
源码大小:66.26M
文件格式:.gz
开发语言:C/C++
更新时间:2021-02-18
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍

Boost是一个功能强大、开源、跨平台、免费的c 程序库,被业界称为“准”c 标准库,能让你的c 开发更加简单,下面就开始下载安装Boost吧。 
1. 下载Boost 
这里选择Unix平台,下载最新的库:boost_1_54_0.tar.gz。 
解压安装包: 
tar -zxvf boost_1_54_0.tar.gz 
下面是boost1.54.0的根目录结构:

boost_1_54_0/ ……………..The “boost root directory” 
index.htm ………A copy of www.boost.org starts here 
boost/ …………………….All Boost Header files

libs/ …………Tests, .cpps, docs, etc., by library 
index.html ……..Library documentation starts here 
algorithm/ 
any/ 
array/ 
…more libraries… 
status/ …………………….Boost-wide test suite 
tools/ ………..Utilities, e.g. Boost.Build, quickbook, bcp 
more/ ……………………..Policy documents, etc. 
doc/ ……………A subset of all Boost library docs

所有的Boost头文件都以.hpp为后缀名,要详细的了解Boost各种库,可以打开libs/index.html文件。

很多Boost库,只需要包含它的头文件即可,头文件已经包含了模板和inline函数,不需要编译成二进制库文件。 
不过下面的这些库必须编译后才能使用。 
Boost.Chrono 
Boost.Context 
Boost.Filesystem 
Boost.GraphParallel 
Boost.IOStreams 
Boost.Locale 
Boost.MPI 
Boost.ProgramOptions 
Boost.Python (see the Boost.Python build documentation before building and installing it) 
Boost.Regex 
Boost.Serialization 
Boost.Signals 
Boost.System 
Boost.Thread 
Boost.Timer 
Boost.Wave 
下面这些库是可选的,只有你在使用某些特定功能时才需要先编译成二进制,具体哪些功能等碰到了再说,先简单了解就行。 
Boost.DateTime 
Boost.Graph 
Boost.Math 
Boost.Random 
Boost.Test 
Boost.Exception

先来实现一个简单的demo,只需要包含Boost相关头文件即可,不需要二进制库。 
创建一个example.cpp文件。

#include <boost/lambda/lambda.hpp> #include <iostream> #include <iterator> #include <algorithm> int main()
{  using namespace boost::lambda;  typedef std::istream_iterator<int> in;  std::for_each(in(std::cin), in(), std::cout << (_1 * 3) << " ");  std::cout << std::endl;
}

该程序很简单,它从标准输入中读取一些数字,然后每个数x3后再输出。 
编译:(-I表示指定#include头文件的目录,编译时会从该目录去查找) 
g -I ~/boost/boost_1_54_0/ ./example.cpp -o example 
运行: 
echo 1 2 3 | ./example 
输出: 
3 6 9

2. 编译安装Boost 
cd boost_1_54_0 
编译前需要配置,输入下面的命令: 
sudo ./bootstrap.sh 
配置后会提示你使用b2(老版本是使用bjam编译)编译,开始编译安装,这里选择完全安装,自定义安装以后再研究,先不浪费时间在这些细节上,输入命令: 
sudo ./b2 install 
编译安装完成后,会把boost头文件拷贝到/usr/local/include/目录下,库文件在/usr/local/lib/下。 
注意:编译安装boost前,得先安装gcc,使用sudo apt-get install build-essential即可。 
build-essential依赖于下面这些软件包,所以安装build-essential时,这些软件也会被安装,很方便。 
|Depends: libc6-dev 
Depends: libc6-dev 
Depends: gcc 
Depends: g  
Depends: make 
Depends: dpkg-dev

使用命令apt-cache depends build-essential可以查看依赖关系。 
再来实现一个简单的demo,需要链接二进制库文件。 
创建example2.cpp文件