(原)ubuntu16中编译boost1.61.0库

转载请注明出处:

http://www.cnblogs.com/darkknightzh/p/5797940.html

参考网址:

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

http://blog.csdn.net/tedious/article/details/6793544

说明:boost库包含两部分:无需编译的头文件,及单独编译的库。单独编译的库如下:

Boost.Chrono

Boost.Context

Boost.Filesystem

Boost.GraphParallel

Boost.IOStreams

Boost.Locale

Boost.MPI

Boost.ProgramOptions

Boost.Python (see the Boost.Python build documentation before building and installing it)

Boost.Regex

Boost.Serialization

Boost.Signals

Boost.System

Boost.Thread

Boost.Timer

Boost.Wave

 

A few libraries have optional separately-compiled binaries:

Boost.DateTime has a binary component that is only needed if you're using its to_string/from_string or serialization features, or if you're targeting Visual C++ 6.x or Borland.

Boost.Graph also has a binary component that is only needed if you intend to parse GraphViz files.

Boost.Math has binary components for the TR1 and C99 cmath functions.

Boost.Random has a binary component which is only needed if you're using random_device.

Boost.Test can be used in “header-only” or “separately compiled” mode, although separate compilation is recommended for serious use.

Boost.Exception provides non-intrusive implementation of exception_ptr for 32-bit _MSC_VER==1310 and _MSC_VER==1400 which requires a separately-compiled binary. This is enabled by #define BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR.

 

安装步骤(首先下载并解压缩文件,并cd到该文件夹内):

1. 运行bootstrap.sh:后面加上需要编译的库(如果不加的话,貌似只会编译最小的库,即包含基本功能的库)需要编译的自己选(可以见参考网址2里面完全编译)。

./bootstrap.sh --with-libraries= system,filesystem, thread,python

经过上命令后,可以看到,会编译哪些库:

2. 运行./b2。直接这样用,提示权限不够,所以使用如下命令就可以成功:

sudo ./b2

成功编译了这些文件(和上图对应的库):

3. 将编译好的文件使用cp命令拷贝到系统的目录:

sudo cp -a stage/lib /usr/local
sudo cp -a boost /usr/local/include/boost

ps. 貌似这些目录不是ubuntu默认的库目录。ubuntu默认库目录是/usr/lib。所以上面拷贝时,可以使用:

sudo cp -a stage/lib /usr
sudo cp -a boost /usr/include

说明:

1. 使用--show-libraries查看哪些需要单独编译:

./bootstrap.sh --show-libraries

2. 全编译(没试过):

./bootstrap.sh --with-libraries= atomic,chrono,container,context,coroutine,coroutine2,date_time,exception,filesystem,graph,graph_parallel,iostreams,locale,with-log,math,metaparse,mpi,program_options,python,random,regex,serialization,signals,system,test,thread,timer,type_erasure,wave

在另一台电脑上,使用./bootstrap.sh --with-libraries= system,filesystem, thread,python,结果全编译出来了。。。

posted on 2016-08-23 09:05  darkknightzh  阅读(6548)  评论(2编辑  收藏  举报

导航