介绍网址:
http://www.linuxfromscratch.org/blfs/view/cvs/general/boost.html
Introduction to Boost
Boost提供了很多基于C++写的库,它包含了 linear algebra, pseudorandom number generation, multithreading, image processing, regular expressions and unit testing等库。
Boost provides a set of free peer-reviewed portable C++ source libraries. It includes libraries for linear algebra, pseudorandom number generation, multithreading, image processing, regular expressions and unit testing.
This package is known to build and work properly using an LFS-8.0 platform.
Package Information
-
Download (HTTP): https://sourceforge.net/projects/boost/files/boost/1.66.0/boost_1_66_0.tar.bz2
- bzip2 -d boost_1_66_0.tar.bz2
- tar -xvf boost_1_66_0.tar
Boost Dependencies
Recommended
Which-2.21
Optional
ICU-58.2, Python-2.7.13 or Python-3.6.0, and Open MPI
User Notes: http://wiki.linuxfromscratch.org/blfs/wiki/boost
Installation of Boost(安装介绍)
First, fix a bug with the header files path, when Python3 is used(我是python2.7,此步骤可以省略):
sed -e '/using python/ s@;@: /usr/include/python${PYTHON_VERSION/3*/${PYTHON_VERSION}m} ;@' \ -i bootstrap.sh
Install Boost by running the following commands:
$ ./bootstrap.sh --prefix=/share/workplace/home/UIUC_fangjingping/software/boost_1_66_0 && ./b2 stage threading=multi link=shared
To run the Boost.Build's regression test (Python-2.7.13 is required),
$ issue pushd tools/build/test;
$ python test_all.py;
$ popd.
All 131 tests should pass.
To run every library's regression tests,
$ issue pushd status;
$ ../b2;
$ popd
. A few tests may fail. They take very long (over 120 SBU at -j1, 50 SBU at -j4) and use a very large amount of disk space (up to 40 GB). You can use the -jN
switch to speed them up.
Now, as the root
user:
./b2 install threading=multi link=shared
装到自己的home下:
$ ./b2 --prefix=/share/workplace/home/UIUC_fangjingping/software/boost_1_66_0 install
测试能否运行,编一个简单的boost程序,并保存为time.cpp:
代码如下:#include
#include
int main()
{
boost::gregorian::date d(boost::gregorian::day_clock::local_day());
std::cout << d.year() << d.month() <
运行:
$ g++ -I ./include -L ./lib time.cpp -o time
$ ./time
2018Jan9
Command Explanations
threading=multi
:这个参数保证boost安装基于多线程支持。This parameter ensures that Boost is built with multithreading support.
link=shared
: 这个参数保证只安装shared库,忽略静态库的安装,因为大部分的软件都不需要静态库,若需要静态库,则不需要加这个参数。This parameter ensures that only shared libraries are created, except for libboost_exception and libboost_test_exec_monitor which are created as static. Most people will not need the static libraries. Indeed most programs using Boost only use the headers. Omit this parameter if you do need static libraries.
-jN
:
设置多线程加速安装过程。这个安装和测试过程需要很久,当设置为-j1时120SBU,-j4时50SBU,需要40GB的空间。This switch may be added to the b2 command lines, to run up to N processes in parallel.
--with-python=python3
: Add this switch to the bootstrap command, if you want Boost to use Python3 instead of Python2.
Contents
Last updated on 2017-02-14 18:20:11 -0600