vs2008编译boost
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 下载可以到官方网站下载:
(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=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”
vs2008编译boost的更多相关文章
- VS2008编译boost库
一.下载首先从boost官方主页http://www.boost.org/下载最新版boost安装包,我用的版本是boost.1.49.0二.新建文件夹 如果是使用下载的安装包,那么请将boost安装 ...
- 编译Boost 详细步骤 适用 VC6 VS2003 VS2005 VS2008 VS2010
vs2008编译boost [一.Boost库的介绍] Boost库是一个经过千锤百炼.可移植.提供源代码的C++库,作为标准库的后备,是C++标准化进程的发动机之一.Boost库由C++标准委员会库 ...
- C++ 系列:编译 boost
Copyright © 1900-2016, NORYES, All Rights Reserved. http://www.cnblogs.com/noryes/ 欢迎转载,请保留此版权声明. -- ...
- 编译Boost 详细步骤
vs2008编译boost [一.Boost库的介绍] Boost库是一个经过千锤百炼.可移植.提供源代码的C++库,作为标准库的后备,是C++标准化进程的发动机之一. Boost库由C++标准委员会 ...
- VS2008下编译BOOST 1.39的ASIO库
由于全部编译BOOST库需要的时间太长,而且耗费空间,况且我只需要用ASIO库,所以就没有必要全部编译了. boost库到www.boost.org上下载. 编译很简单,假设你的boost存放的目录是 ...
- VS2010编译Boost 1.57 静态链接库
http://www.cnblogs.com/cuish/p/4175491.html 0.前提 Boost库版本 1.57.0 下载地址 http://www.boost.org/users/his ...
- windows下用vs2008和boost结合编译程序
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://co63oc.blog.51cto.com/904636/504469 win ...
- 编译mapnik(win7 环境下vs2008编译mapnik 0.7.1 成功)
编译mapnik(win7 环境下vs2008编译mapnik 0.7.1 成功) ------by wangsh 2012.02.22 Mapnik 是一个开源的 Python/C++ 地图渲染引 ...
- vs2008编译FileZilla服务端源码
vs2008编译FileZilla服务端源码 FileZilla服务端下载地址:https://download.filezilla-project.org/server/.FileZilla服务端源 ...
随机推荐
- USACO Section 2.4: The Tamworth Two
这题我是用蒙的方法来弄出最后的不能碰到的条件的(用1000试了下account跳出条件),结果竟然还过了,不过网上有精准的求出这个碰不到的条件,farm的状态为10*10*4 = 400,cow的状态 ...
- GitHub 教程 in Ubuntu
Follow these steps to configure github if you are the first time to use Github 1. Sign up a username ...
- ubuntu添加环境变量【原创】
cpro放到环境变量里,并且加上可执行权限如果在本地添加,则需mkdir ~/bin mv cpro /home/zhangbh/bin/vi ~/.bashrcexport PATH=/usr/lo ...
- dojo 资源库
文档 :http://wenku.baidu.com/link?url=Nnek_tAjIC-Q3t3e9zHQmsh4LhU3f0ncC1QH8WD_U9-I8-fJ7mMisscFpgfuS8nU ...
- Python自带包建立简单web服务器
在DOS里cd到准备做服务器根目录的路径下,输入命令: python -m Web服务器模块 [端口号,默认8000] 例如: python -m SimpleHTTPServer 8080 然后就可 ...
- Android开源库--Universal Image Loader通用图片加载器
如果说我比别人看得更远些,那是因为我站在了巨人的肩上. github地址:https://github.com/nostra13/Android-Universal-Image-Loader 介绍 ...
- Sass中的mixin,function,extend
Mixins: 用于相类似的css属性将会被使用多次,每次调用时仅仅有小的参数改变: Function 用于计算得出相关值: Extend 有一批属性完全匹配时,应该使用extend
- poj2750 线段树 +DP Potted Flower
问题描述:给定一个环形序列,进行在线操作,每次修改一个元素,输出环上的最大连续子列的和,但不能是完全序列. 算法:把环从一个地方,切断拉成一条直线,用线段树记录当前区间的非空最大子列和当前区间的非空最 ...
- 剑指offer-第二章排序之年龄排序
题目:对某个公司的人的年龄(0-99)进行排序,该公司的总人数为几万人.要求时间复杂度为O(n),可以辅助O(n)的空间. 思路:实现函数为void SortAge(int ages[],int le ...
- Java中Volatile关键字详解
一.基本概念 先补充一下概念:Java并发中的可见性与原子性 可见性: 可见性是一种复杂的属性,因为可见性中的错误总是会违背我们的直觉.通常,我们无法确保执行读操作的线程能适时地看到其他线程写入的值, ...