Boost的编译

下载Boost源代码与安装VS

博主使用的是版本boost_1_61_0、vs2008或者vs2010

1.解压boost文件,使用编译器的命令行进入解压后的根目录

2.敲入命令.\bootstrap.bat (on Windows)或者./bootstrap.sh (on other operating systems)

3.执行./b2 install --prefix=PREFIX

PREFIX就是你要安装的目录位置,Win32默认在 C:\Boost;Unix默认在 /usr/local on Unix. Linux

4.可选的。可以将PREFIX/bin设置为环境变量方便使用

下面就是开始boost的hello之旅了

http://blog.csdn.net/xinqingwuji/article/details/51737177

博主使用的命令:b2 stage --toolset=msvc-9.0 variant=debug link=shared threading=multi runtime-link=shared

20170420补充

使用动态库链接还是乖乖的,运行时还需要一堆动态库,后来还是从了静态库。。。。

修改为b2 install --toolset=msvc-10.0 variant=debug link=static threading=multi runtime-link=shared


仅供参看,使用都是动态链接

详细解释:

第二步执行后在boost根目录(也是bootstrap.bat的目录)下会生成b2.exe、bjam.exe、project-config.jam、bootstrap.log四个文件。

第三步执行的是默认安装。可以键入b2 --help来查看编译的配置情况。


博主参考的配置参数:

b2 stage/install

重要参数说明:

[install|stage]:

stage:只在stage目录下放置编译的库文件,可以由--stagedir=<STAGEDIR>选项来指定目录。默认是根目录stage目录下。

install:会生成一些boost的头文件目录include文件,直接使用。

toolset:

win32下的版本msvc-6.0 :  VC6.0    msvc-7.0:  VS2003    msvc-8.0:  VS2005    msvc-9.0:  VS2008    msvc-10.0:  VS2010

--with-<library>:指定编译的库

--without-<library>:指定不编译的库。默认是全编译的

--show-libraries:显示需要编译的全部库文件

variant=debug|release 编译的版本debug或者release

link=static|shared  静态或者动态编译库

threading=single|multi  单线程或者多线程。一般当然还是多线程环境多。

runtime-link=static|shared  静态链接或者动态链接C/C++运行库

--build-type=<type>:

complete  编译所有可能的变量,相当于variant=release,threading=multi;link=shared|static;runtime-link=shared


Boost库命名特点:

1.包含boost单词

2.link=static,生成的库lib开头,然后再接boost

3.threading=mult,生成的库加入关键词-mt

4.variant=debug,生成的库加入关键词-gd

5.runtime-link=static,生成的库加入关键词-s





b2的全部参数

 Usage:


   b2 [options] [properties] [install|stage]


   Builds and installs Boost.


 Targets and Related Options:


   install                 Install headers and compiled library files to the
   =======                 configured locations (below).


   --prefix=<PREFIX>       Install architecture independent files here.
                           Default; C:\Boost on Win32
                           Default; /usr/local on Unix. Linux, etc.


   --exec-prefix=<EPREFIX> Install architecture dependent files here.
                           Default; <PREFIX>


   --libdir=<DIR>          Install library files here.
                           Default; <EPREFIX>/lib


   --includedir=<HDRDIR>   Install header files here.
                           Default; <PREFIX>/include


   stage                   Build and install only compiled library files to the
   =====                   stage directory.


   --stagedir=<STAGEDIR>   Install library files here
                           Default; ./stage


 Other Options:


   --build-type=<type>     Build the specified pre-defined set of variations of
                           the libraries. Note, that which variants get built
                           depends on what each library supports.


                               -- minimal -- (default) Builds a minimal set of
                               variants. On Windows, these are static
                               multithreaded libraries in debug and release
                               modes, using shared runtime. On Linux, these are
                               static and shared multithreaded libraries in
                               release mode.


                               -- complete -- Build all possible variations.


   --build-dir=DIR         Build in this location instead of building within
                           the distribution tree. Recommended!


   --show-libraries        Display the list of Boost libraries that require
                           build and installation steps, and then exit.


   --layout=<layout>       Determine whether to choose library names and header
                           locations such that multiple versions of Boost or
                           multiple compilers can be used on the same system.


                               -- versioned -- Names of boost binaries include
                               the Boost version number, name and version of
                               the compiler and encoded build properties. Boost
                               headers are installed in a subdirectory of
                               <HDRDIR> whose name contains the Boost version
                               number.


                               -- tagged -- Names of boost binaries include the
                               encoded build properties such as variant and
                               threading, but do not including compiler name
                               and version, or Boost version. This option is
                               useful if you build several variants of Boost,
                               using the same compiler.


                               -- system -- Binaries names do not include the
                               Boost version number or the name and version
                               number of the compiler. Boost headers are
                               installed directly into <HDRDIR>. This option is
                               intended for system integrators building
                               distribution packages.


                           The default value is 'versioned' on Windows, and
                           'system' on Unix.


   --buildid=ID            Add the specified ID to the name of built libraries.
                           The default is to not add anything.


   --python-buildid=ID     Add the specified ID to the name of built libraries
                           that depend on Python. The default is to not add
                           anything. This ID is added in addition to --buildid.


   --help                  This message.


   --with-<library>        Build and install the specified <library>. If this
                           option is used, only libraries specified using this
                           option will be built.


   --without-<library>     Do not build, stage, or install the specified
                           <library>. By default, all libraries are built.


 Properties:


   toolset=toolset         Indicate the toolset to build with.


   variant=debug|release   Select the build variant


   link=static|shared      Whether to build static or shared libraries


   threading=single|multi  Whether to build single or multithreaded binaries


   runtime-link=static|shared
                           Whether to link to static or shared C and C++
                           runtime.




  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

道格拉斯范朋克

播种花生牛奶自留田

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

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

打赏作者

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

抵扣说明:

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

余额充值