Linux 下 Boost 配置 . bootstrap.sh , b2 ,bcp 使用.

Linux 下 Boost 配置 . bootstrap.sh , b2 ,bcp 使用.


下载官方链接

http://sourceforge.net/projects/boost/files/

你会下载到一个70+M 的压缩包 . 我下载的是版本 1.57.0 解压后放置到你的工作目录 , 比如 ~/test/boost

编译安装官方链接

http://www.boost.org/doc/libs/1_57_0/more/getting_started/unix-variants.html

boost 和STL 很相似, 大量使用了模板, 所以boost的很多模块是可以直接使用的, 但是仍然有些模块是需要先编译的:

以下模块需要单独编译链接才可以使用

Boost.ChronoBoost.ContextBoost.FilesystemBoost.GraphParallelBoost.IOStreamsBoost.LocaleBoost.MPIBoost.ProgramOptionsBoost.Python (see the Boost.Python build documentation before building and installing it)Boost.RegexBoost.SerializationBoost.SignalsBoost.SystemBoost.ThreadBoost.TimerBoost.Wave

一次性编译安装 – boostrap , b2配置环境, 生产编译工具

Linux 使用 bootstrap.sh 来生产编译工具 b2 . 同时可以配置安装路径 , 默认的安装路径是 /usr/local . 假设我们将生产的库文件放置到 ~/test/boostlib 中.

cd ~/test/boost ./bootstrap.sh – -prefix=/home/your_user_name/test/boostlib

这里不要使用 ~ 符号 , 我的版本不支持,它会在当前目录下生产一个名字为~的文件夹 🙁 大概以后会支持吧.

官方说明链接

http://www.boost.org/build/doc/html/index.html

这样就生产了工具 b2, 它实际上是个支持 Boost.Jam语言的使用本地编译器自动化编译链接的跨平台编译工具, . 链接里面有详细的使用说明, 我们甚至可以使用它来编译我们自己的工程.

编译安装

./b2 install

或者需要重新指定安装路径的时候:

./ b2 install – -prefix= path_your_need

链接库命名规则

-lboost_XXX

这样添加上 include 路径和 lib 路径后, 我们就可以在自己的工程中使用 boost 了.

boost 库裁剪 – bcp

boost库是非常庞大的, 下载的压缩包就 70M+ , 安装的文件夹足足有150M . 我们在自己的工程中一般不会使用boost的所以模块 ,所以boost 提供了 bcp 工具来裁剪boost库.

官方文档

http://www.boost.org/doc/libs/1_57_0/tools/bcp/doc/html/index.html

编译bcp

./b2 tools/bcp

这样会生产一个名叫dist的文件夹, dist/bin/bcp 就是我们需要的工具 .

然后就可以使用bcp 参见boost 库.

./disk/bin/bcp … … … folder 比如: bcp atomic chrono filesystem program_options regex system thread algorithm any array assert assign bind circular_buffer container foreach function functional/hash integer interprocess lexical_cast lockfree mem_fn move mpl operators optional random ref signals2 smart_ptr static_assert tokenizer tuple type_traits typeof unordered utility build .\boost_slim

我使用的版本bcp有问题 , 1.55.0 版本的还好用. 裁剪出来的就是一个独立的boost小库, 可以独立编译链接使用.

上帝从不埋怨人们的愚昧,人们却埋怨上帝的不公平

Linux 下 Boost 配置 . bootstrap.sh , b2 ,bcp 使用.

相关文章:

你感兴趣的文章:

标签云: