vs2008编译boost

【一、Boost库的介绍】

Boost库是一个经过千锤百炼、可移植、提供源代码的C++库,作为标准库的后备,是C++标准化进程的发动机之一。Boost库由C++标准委员会库工作组成员发起,其中有些内容有望成为下一代C++标准库内容。在C++社区中影响甚大,其成员已近2000人。 Boost库为我们带来了最新、最酷、最实用的技术,是不折不扣的“准”标准库。

Boost库中比较有名的几个库:

(1)Regex,正则表达式库;

(2)Spirit,LL parser framework,用C++代码直接表达EBNF;

(3)Graph,图组件和算法;

(4)Lambda,在调用的地方定义短小匿名的函数对象,很实用的functional功能;

(5)concept check,检查泛型编程中的concept;

(6)Mpl,用模板实现的元编程框架;

(7)Thread,可移植的C++多线程库;

(8)Python,把C++类和函数映射到Python之中;

(9)Pool,内存池管理;

(10)smart_ptr,智能指针。

【二、Boost库的编译】

【Setp1 准备工作】:

(1)Boost 下载可以到官方网站下载:

http://www.boost.org/

(2)安装VS2008 IDE

【Setp2 编译Boost】

1.打开Visual Studio 2008 命令提示窗口

2.进入D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/boost_1_44_0/tools/jam/src

3.执行 build.bat 会在D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/boost_1_44_0

/tools/jam/src/bin.ntx86 生成 bjam.exe文件.

4.Copy bjam.exe 文件到 D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/boost_1_44_0 下

6.进入D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/boost_1_44_0 目录

7.执行bjam.exe 编译命令,如下:

(1)编译所有boost动态库 (release|debug),包括头文件和库文件

bjam --toolset=msvc-9.0 --prefix=D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/output --without-python --build-type=complete  link=shared  threading=multi install

(2)只编译 release 版本 regex 动态库,包括头文件和库文件

bjam --toolset=msvc-9.0 --prefix=D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/output1 --with-regex link=shared threading=multi variant=release runtime-link=shared  install

(3)只编译 release 版本 regex 动态库,包括库文件

bjam --toolset=msvc-9.0

--stagedir=D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/output2

--with-regex link=shared  threading=multi variant=release runtime-link=shared  stage

【注意】: Boost 源代码所在路径最好全英文,不要有空格、特殊字符、中文等

编译要花上30分钟左右(根据PC性能所定), 会在指定生成目录:

D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/output下生成对应库文件和头文件。

8.设置开发环境

打开VS2008 创建工程, 配置工程属性

设置包含文件目录F:/Develop/BoostlibAndDll/include/boost-1_37/boost

设置引用文件目录:F:/Develop/BoostlibAndDll/lib

完成后,可以使用。

【三、介绍Bjam使用】

Usage:

Bjam  [options]  [properties]  [install|stage]

install                 Install  headers and compiled library files to the

=======               configured locations (below).

在“--prefix=”指定的目录下生成所有头文件

(boost源代码下boost文件夹下所有文件)和指定库文件

--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=<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 the single

"release" version of the libraries. This

release corresponds to specifying:

"release  <threading>multi  <link>shared

<link>static  <runtime-link>shared" as the

Build variant to build.

complete - Attempts to build all possible

variations.

--build-dir=DIR         Build in this location instead of building

within the distribution tree. Recommended!

--show-libraries        Displays the list of Boost libraries that require

build and installation steps, then exit.

--layout=<layout>       Determines 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 (default) - Names of boost

binaries include the Boost version

number and the name and version of the

compiler. Boost headers are installed

in a subdirectory of <HDRDIR> whose

name contains the Boost version number.

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 who

are building distribution packages.

--buildid=ID                    Adds the specified ID to the name of built

libraries. The default is to not add anything.

--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            Indicates the toolset to build with.

msvc-6.0 :  VC6.0

msvc-7.0:  VS2003

msvc-8.0:  VS2005

msvc-9.0:  VS2008

msvc-10.0:  VS2010

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.

决定是静态还是动态链接C/C++标准库

Bjam 选项、参数说明

--build-dir=<builddir>

编译的临时文件会放在builddir里(编译完就可以把它删除了)

--stagedir=<stagedir>

存放编译后库文件的路径,默认是stage

--build-type=complete

编译所有版本,不然只会编译一小部分版本(相当于:
variant=release,threading=multi;
link=shared|static;runtime-link=shared)

variant=debug|release

决定编译什么版本(Debug or Release)

link=static|shared

决定使用静态库还是动态库

threading=single|multi

决定使用单线程还是多线程库

runtime-link=static|shared

决定是静态还是动态链接C/C++标准库

--with-<library>

只编译指定的库,如输入--with-regex就只编译regex库了

--show-libraries

显示需要编译的库名称

【四、Bjam 生成文件的分析】

(1)生成 Release 版本,多线程,动态链接C++标准库 的regex 动态库

bjam --toolset=msvc-9.0

--stagedir=D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/output2

--with-regex   link=shared  threading=multi  variant=release  runtime-link=shared  stage

-- 输出: boost_regex-vc90-mt.lib

boost_regex-vc90-mt-1_44.lib

boost_regex-vc90-mt-1_44.dll

(2)生成 Release 版本,多线程,静态链接C++标准库 的regex 动态库

bjam --toolset=msvc-9.0

--stagedir=D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/output2

--with-regex   link=shared  threading=multi  variant=release  runtime-link= static  stage

-- 输出: 没有这种配置

(3)生成 Release 版本,多线程,动态链接C++标准库 的regex静态库

bjam --toolset=msvc-9.0

--stagedir=D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/output2

--with-regex   link= static  threading=multi  variant=release  runtime-link=shared  stage

-- 输出: libboost_regex-vc90-mt-s.lib

libboost_regex-vc90-mt-1_44.lib

(4)生成 Release 版本,多线程,静态链接C++标准库 的regex 静态库

bjam --toolset=msvc-9.0

--stagedir=D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/output3

--with-regex  link=static  threading=multi  variant=release  runtime-link=static  stage

-- 输出:libboost_regex-vc90-mt-s.lib

libboost_regex-vc90-mt-s-1_44.lib

--------------------------------------------------------------------------------------------------------------------

(1)生成 Debug 版本,多线程,动态链接C++标准库 的regex 静态库

bjam --toolset=msvc-9.0

--stagedir=D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/output4

--with-regex  link=static  threading=multi  variant=debug runtime-link=shared  stage

-- 输出: libboost_regex-vc90-mt-gd.lib

libboost_regex-vc90-mt-gd-1_44.lib

(2)生成 Debug 版本,多线程,静态链接C++标准库 的regex 静态库

bjam --toolset=msvc-9.0

--stagedir=D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/output5

--with-regex   link=static  threading=multi  variant=debug  runtime-link=static  stage

-- 输出: libboost_regex-vc90-mt-sgd.lib

libboost_regex-vc90-mt-sgd-1_44.lib

(3)生成 Debug 版本,多线程,动态链接C++标准库 的regex 动态库

bjam --toolset=msvc-9.0

--stagedir=D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/output5

--with-regex   link=shared  threading=multi  variant=debug  runtime-link=shared  stage

- 输出: boost_regex-vc90-mt-gd.lib

boost_regex-vc90-mt-gd-1_44.lib

boost_regex-vc90-mt-gd-1_44.dll

(4)生成 Debug 版本,多线程,静态链接C++标准库 的regex动态库

bjam --toolset=msvc-9.0

--stagedir=D:/05_Computer/04_3rdPatry/02Boost/boost_1_44_0/output5

--with-regex   link=shared  threading=multi  variant=debug  runtime-link=static  stage

-- 输出:没有这种配置

【总结】:

(1)       编译成功后,Bjam 都会给你生成一对一样的导入库文件或者静态库文件(如下),

唯一不同的是两个文件名称一个在后面加上了boost版本信息, 为了让用户知道使用的boost的版本信息。

boost_regex-vc90-xxxxx.lib

boost_regex-vc90-xxxxx-1_44.lib

(2)       Bjam编译选项 有4个, 理论上应该有 2*2*2*2 = 16 种配置

ink= static| shared

threading= single |multi

variant=release|debug

runtime-link= static |shared

实际使用的多为多线程, 所以 threading= multi, 这样剩下的3个选项组成的编译配置就是上面所罗列的, 其中静态链接C++标准库的boost动态库这种配置也不存在, 所以就只有4种情况。

(3)

link= static : 静态库。 生成的库文件名称以 “lib”开头

link= shared : 动态库。生成的库文件名称无“lib”开头

threading= mult : 支持多线程。 生成的库文件名称中包含 “-mt”

variant=release  生成的库文件名称不包含 “-gd”

variant= debug  生成的库文件名称包含 “-gd”

runtime-link= static  生成的库文件名称包含 “-s”

runtime-link= shared  生成的库文件名称不包含 “-s”

编译Boost 详细步骤 适用 VC6 VS2003 VS2005 VS2008 VS2010的更多相关文章

  1. Atitit. visual studio vs2003 vs2005 vs2008  VS2010 vs2012 vs2015新特性 新功能.doc

    Atitit. visual studio vs2003 vs2005 vs2008  VS2010 vs2012 vs2015新特性 新功能.doc 1.1. Visual Studio2 1.2. ...

  2. 编译Boost 详细步骤

    vs2008编译boost [一.Boost库的介绍] Boost库是一个经过千锤百炼.可移植.提供源代码的C++库,作为标准库的后备,是C++标准化进程的发动机之一. Boost库由C++标准委员会 ...

  3. 编译Chrome详细步骤

    编译Chrome详细步骤   文章来源:http://blog.csdn.net/allendale/article/details/9262833 参考:http://dev.chromium.or ...

  4. mysql 5.6.25编译安装详细步骤

    简略步骤: mysql5.6.25编译安装步骤: 下载mysql准备用户和组yum安装依赖解压mysqlcmake编译mysqlmake && make install ----时间约 ...

  5. 01.LNMP架构-Nginx源码包编译部署详细步骤

    操作系统:CentOS_Server_7.5_x64_1804.iso 部署组件:Pcre+Zlib+Openssl+Nginx 操作步骤: 一.创建目录 [root@localhost ~]# mk ...

  6. 02.LNMP架构-MySQL源码包编译部署详细步骤

    操作系统:CentOS_Server_7.5_x64_1804.iso 部署组件:Cmake+Boost+MySQL 操作步骤: 一.安装依赖组件 [root@localhost ~]# yum -y ...

  7. 在WSL Ubuntu 下编译UPX详细步骤

    准备环境: 1. sudo apt-get update 2. sudo apt-get clang 3. apt-get install libstdc++-dev Reading package ...

  8. 下载编译Chrome详细步骤

    文章来源:http://blog.csdn.net/allendale/article/details/9262833 参考:http://dev.chromium.org/developers/ho ...

  9. 03.LNMP架构-PHP源码包编译部署详细步骤

    一.环境准备 操作系统:CentOS_Server_7.5_x64_1804.iso 部署组件:yasm+libmcrypt+libvpx+tiff+libpng+freetype+jpeg+libg ...

随机推荐

  1. 2014 HDU多校弟九场I题 不会DP也能水出来的简单DP题

    听了ZWK大大的思路,就立马1A了 思路是这样的: 算最小GPA的时候,首先每个科目分配到69分(不足的话直接输出GPA 2),然后FOR循环下来使REMAIN POINT减少,每个科目的上限加到10 ...

  2. POJ 2187 旋转卡壳 + 水平序 Graham 扫描算法 + 运算符重载

    水平序 Graham 扫描算法: 计算二维凸包的时候可以用到,Graham 扫描算法有水平序和极角序两种. 极角序算法能一次确定整个凸包, 但是计算极角需要用到三角函数,速度较慢,精度较差,特殊情况较 ...

  3. struts2总结【转载】

    1,struts2的form表单里面和url里面的传值以及Action所继承的父类都可以自动set属性注入action中,及继承的action中. 2,凡是url和form表单传值,在action方法 ...

  4. ASP.NET MVC 5 学习教程:修改视图和布局页

    原文 ASP.NET MVC 5 学习教程:修改视图和布局页 起飞网 ASP.NET MVC 5 学习教程目录: 添加控制器 添加视图 修改视图和布局页 控制器传递数据给视图 添加模型 创建连接字符串 ...

  5. 比较优势 - MBA智库百科

    比较优势 - MBA智库百科 比较优势 出自 MBA智库百科(http://wiki.mbalib.com/)   这是一个消除歧义页--使用相同或相近标题,而主题不同的条目列表.如果您是通过某个内部 ...

  6. 运行计划之误区,为什么COST非常小,SQL却跑得非常慢?

    转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/38321477 2014.7.31就晚20:30 My Oracle Support组猫大师 ...

  7. 关于C++的子类指针指向父类

    基类指针引用派生类对象 用基类指针引用一个派生类对象,由于派生类对象也是基类的对象,所以这种引用是安全的; 但是只能引用基类成员. 若试图通过基类指针引用那些只在派生类中才有的成员,编译器会报告语法错 ...

  8. SGU 106 The Equation 扩展欧几里得应用

    Sol:线性不定方程+不等式求解 证明的去搜下别人的证明就好了...数学题. #include <algorithm> #include <cstdio> #include & ...

  9. iOS开发之XMPP即时通讯简单实现

    首先搭载服务器和数据库 搭载服务器我用的是openfire,数据库用的是mysql 这里推荐两个链接 配置mysql,用的是mysql workbench http://justsee.iteye.c ...

  10. char、signed char 和 unsigned char 的区别

    ANSI C 提供了3种字符类型,分别是char.signed char.unsigned char.而不是像short.int一样只有两种(int默认就是signed int). 三者都占1个字节( ...