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


关于 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(四)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

1AI

请我喝杯伯爵奶茶~!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值