boost 库是c++标准库的拓展,很实用。
赶紧提升C++技能。
因为有个游戏安装需要下载boost库,查阅晚上相关文档,这么好的库应该极大地发扬光大才是啊。
官网http://www.boost.org/
下载地址
https://sourceforge.net/projects/boost/files/boost/1.63.0/
访问有点慢的话访问百度网盘下载。
https://pan.baidu.com/s/1bpKPKsf
安装,可以看到非常简单,还提供学习网站。
指导手册
file:///home/wang/Downloads/boost_1_63_0/more/getting_started/unix-variants.html#build-a-simple-program-using-boost
也可以指定安装目录,具体查询--help解决。
./bootstrap.sh --prefix=/usr
./b2 install
wang@wang:~/Downloads/boost_1_63_0$ ./bootstrap.sh
Building Boost.Build engine with toolset gcc... tools/build/src/engine/bin.linuxx86_64/b2
Detecting Python version... 2.7
Detecting Python root... /usr
Unicode/ICU support for Boost.Regex?... not found.
Generating Boost.Build configuration in project-config.jam...
Bootstrapping is done. To build, run:
./b2
To adjust configuration, edit 'project-config.jam'.
Further information:
- Command line help:
./b2 --help
- Getting started guide:
http://www.boost.org/more/getting_started/unix-variants.html
- Boost.Build documentation:
http://www.boost.org/build/doc/html/index.html
执行./b2
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
/home/wang/Downloads/boost_1_63_0
The following directory should be added to linker library paths:
/home/wang/Downloads/boost_1_63_0/stage/lib
执行
./bjam
可以看到已经安装完成。
写一个程序进行测试说明
#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) << " " );
}
wang@wang:~$ g++ -I /home/wang/Downloads/boost_1_63_0 labmda.cpp -o lambda
wang@wang:~$ echo 1 2 3 | ./example
bash: ./example: No such file or directory
wang@wang:~$ echo 1 2 3 | ./lambda
3 6 9 wang@wang:~$
结果,正确安装。