boost(bjam) - 安装(Mac/Linux)

慕和惬
2023-12-01


关于 boost

Boost provides free peer-reviewed portable C++ source libraries.


Ubuntu

参考:http://www2.statmt.org/moses/?n=Development.GetStarted
下载链接可能会改变,可看:https://www.boost.org/users/download/

wget  https://boostorg.jfrog.io/artifactory/main/release/1.81.0/source/boost_1_81_0.tar.gz
tar zxvf  boost_1_81_0.tar.gz
cd boost_1_81_0/
./bootstrap.sh 
./b2 -j4 --prefix=$PWD --libdir=$PWD/lib64 --layout=system link=static install || echo FAILURE
  • 将在 lib64 文件夹下生成库文件,而非系统文件夹;因此你并不需要root权限来运行;

macOS


1、使用 brew 安装

使用 brew时,bjam 和 boost 是分开安装的。

$ brew install boost 

$ brew install bjam

2、源码安装

1、下载源码

https://www.boost.org/users/download/


2、Bootstrapping :Building B2 engine

$ cd .../boost_1_79_0 
$ ./bootstrap.sh 

# 带选项
$ ./bootstrap.sh --with-libraries=all --with-toolset=clang

编译完成后,bjam 会被安装在 tools/build/src/engine/b2 目录下。

通过编辑 project-config.jam 来使用 --with-toolset 选项或调整配置。


# 查看 bjam 版本
$ cd tools/build/src/engine 
$ ./bjam  --version
B2 4.8-git
 
# 查看帮助 
$ ./b2 --help


3、build

# 编译, 带上 -j8 命令 ,不然就是单核心编译
$ ./b2 -j8

# clean
./b2 clean -j8

# 生成头文件
./b2 headers
$ ./b2 -h
Invalid option: -h

usage: ./b2 [ options ] targets...

-a      Build all targets, even if they are current.
-dx     Set the debug level to x (0-13,console,mi).
-fx     Read x instead of bootstrap.
-jx     Run up to x shell commands concurrently.
-lx     Limit actions to x number of seconds after which they are stopped.
-mx     Maximum target output saved (kb), default is to save all output.
-n      Don't actually execute the updating actions.
-ox     Mirror all output to file x.
-px     x=0, pipes action stdout and stderr merged into action output.
-q      Quit quickly as soon as a target fails.
-sx=y   Set variable x=y, overriding environment.
-tx     Rebuild x, even if it is up-to-date.
-v      Print the version of jam and exit.
--x     Option is ignored.

安装成功后,安装包地址位于 /usr/local/Cellar/boost/
并软链接到 /usr/local/include/usr/local/lib
你可以在 /usr/local/lib 下找到 libboost_* 文件


在 xcode 中使用 boost 库

可参考文章:https://huangkx.blog.csdn.net/article/details/80323743


伊织 2022-06-23(四)

 类似资料: