1、目录结构说明
在boost官网下载boost压缩文件(我用的是boost_1_74_0.zip这个版本),解压后主要目录结构说明如下:
2、安装
安装Boost所需的依赖库,主要的是icu以获取boost :: regex支持:
sudo apt-get update
sudo apt-get install build-essential g++ python-dev autotools-dev libicu-dev build-essential libbz2-dev
Boost的引导程序设置(自定义安装路径,比如“/usr/local”):
wyr@iZm5e9phbzdxx0lysrv9t2Z:~/packages/boost_1_78_0$ ls
boost boostcpp.jam boost.png bootstrap.sh index.htm INSTALL libs more rst.css tools
boost-build.jam boost.css bootstrap.bat doc index.html Jamroot LICENSE_1_0.txt README.md status
wyr@iZm5e9phbzdxx0lysrv9t2Z:~/packages/boost_1_78_0$
运行以下命令:
./bootstrap.sh --prefix=/home/wyr/develop/3thparty
wyr@iZm5e9phbzdxx0lysrv9t2Z:~/packages/boost_1_78_0$ ./bootstrap.sh --prefix=/home/wyr/develop/3thparty
Building B2 engine..
###
###
### Using 'gcc' toolset.
###
###
g++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
###
###
> g++ -x c++ -std=c++11 -O2 -s -DNDEBUG builtins.cpp class.cpp command.cpp compile.cpp constants.cpp cwd.cpp debug.cpp debugger.cpp execcmd.cpp execnt.cpp execunix.cpp filesys.cpp filent.cpp fileunix.cpp frames.cpp function.cpp glob.cpp hash.cpp hcache.cpp hdrmacro.cpp headers.cpp jam_strings.cpp jam.cpp jamgram.cpp lists.cpp make.cpp make1.cpp md5.cpp mem.cpp modules.cpp native.cpp object.cpp option.cpp output.cpp parse.cpp pathnt.cpp pathsys.cpp pathunix.cpp regexp.cpp rules.cpp scan.cpp search.cpp startup.cpp subst.cpp sysinfo.cpp timestamp.cpp variable.cpp w32_getreg.cpp modules/order.cpp modules/path.cpp modules/property-set.cpp modules/regex.cpp modules/sequence.cpp modules/set.cpp -o b2
> cp b2 bjam
tools/build/src/engine/b2
Detecting Python version... 2.7
Detecting Python root... /usr
Unicode/ICU support for Boost.Regex?... /usr
Backing up existing B2 configuration in project-config.jam.1
Generating B2 configuration in project-config.jam for gcc...
Bootstrapping is done. To build, run:
./b2
To generate header files, run:
./b2 headers
The configuration generated uses gcc to build by default. If that is
unintended either use the --with-toolset option or adjust configuration, by
editing 'project-config.jam'.
Further information:
- Command line help:
./b2 --help
- Getting started guide:
http://www.boost.org/more/getting_started/unix-variants.html
- B2 documentation:
http://www.boost.org/build/
wyr@iZm5e9phbzdxx0lysrv9t2Z:~/packages/boost_1_78_0$
如果我们需要MPI,则需要在user-config.jam文件中设置标志(user-config.jam文件可以在Boost根目录中创建):
user_configFile=`find $PWD -name user-config.jam` echo "using mpi ;" >> $user_configFile
安装Boost:
# 查找最大物理核数:
n=`cat /proc/cpuinfo | grep "cpu cores" | uniq | awk '{print $NF}'`
# 安装
./b2 --with=all -j $n install
C++ | boost库入门_烫青菜的博客-CSDN博客_boost库
在Ubuntu上安装Boost的五种方法(全网最全,建议收藏)_小熊coder的博客-CSDN博客_ubuntu boost