boost库生成文件命名和编译
生成文件命名规则:boost中有许多库,有的库需要编译、而有的库不需要编译,只需包含头文件就可以使用。编译生成的文件名字普遍较长,同一个库根据编译链接选项不同,又可以生成多个不同名字的文件。生成的文件名字是很长,可是这样带的信息才多,也就容易识别出用途。其实生成文件的名字遵循一定的规则,有着固定的格式。识别这种格式,能帮助我们更高效地使用boost库。生成文件名字格式如:
BOOST_LIB_PREFIX + BOOST_LIB_NAME + "-" + BOOST_LIB_TOOLSET + "-" + BOOST_LIB_THREAD_OPT + "-" + BOOST_LIB_RT_OPT + "-" + BOOST_LIB_VERSION
这些定义为:
BOOST_LIB_PREFIX: 静态库为 "lib" (否则无,是用动态链接库)
BOOST_LIB_NAME: 库的基本名称 ( 比方说 boost_regex).
BOOST_LIB_TOOLSET: 编译工具集名称 ( 比如:vc6, vc7, bcb5 )
BOOST_LIB_THREAD_OPT: 多线程为 "-mt" ,否则为空
BOOST_LIB_RT_OPT: 指示使用的运行库的后缀,
组合下面的一个或者更多字符:
s 静态运行库,指的是静态链接到运行时库(不出现表示动态).
g 调试/诊断 runtime (release if not present).
d 调试版本 (不出现表示 release 版 ).
p STLPort 版本.
注:对 vc 来说,gd 总是一起出现
BOOST_LIB_VERSION: Boost 版本, Boost 版本 x.y 表示为 x_y形式.
编译:为了简化boost库的编译,boost库中带了一个用来编译的工具,名字是bjam.exe或者b2.exe.
1:运行boost下的bootstap.bat脚本就会自动生上述的两个编译工具,并且拷贝到boost目录下. 也可以进入tools/build目录下找到类似的脚本或者项目源码来编译.
2: bjam.exe的参数
Feature |
Allowed values |
Notes |
variant |
debug,release |
|
link |
shared,static |
Determines if Boost.Build creates shared or static libraries |
threading |
single,multi |
Cause the produced binaries to be thread-safe. This requires proper support in the source code itself. |
address-model |
32,64 |
Explicitly request either 32-bit or 64-bit code generation. This typically requires that your compiler is appropriately configured. Please refer to the section called “C++ Compilers” and your compiler documentation in case of problems. |
toolset |
(Depends on configuration) |
The C++ compiler to use. See the section called “C++ Compilers” for a detailed list. (Vs2008)msvc-8.0 (vs2010)msvc-10.0 |
include |
(Arbitrary string) |
Additional include paths for C and C++ compilers. |
define |
(Arbitrary string) |
Additional macro definitions for C and C++ compilers. The string should be either SYMBOL or SYMBOL=VALUE |
cxxflags |
(Arbitrary string) |
Custom options to pass to the C++ compiler. |
cflags |
(Arbitrary string) |
Custom options to pass to the C compiler. |
linkflags |
(Arbitrary string) |
Custom options to pass to the C++ linker. |
runtime-link |
shared,static |
Determines if shared or static version of C and C++ runtimes should be used. |
--build-dir=<builddir> |
编译的临时文件会放在builddir里(这样比较好管理,编译完就可以把它删除了) |
--stagedir=<stagedir> |
存放编译后库文件的路径,默认是stage |
--build-type=complete |
编译所有版本,不然只会编译一小部分版本(确切地说是相当于:variant=release, threading=multi;link=shared|static;runtime-link=shared) |
variant=debug|release |
决定编译什么版本(对应文件中的d 调试版本 不出现表示 release 版) |
link=static|shared |
决定使用静态库还是动态库。(对应文件中的BOOST_LIB_PREFIX ) |
threading=single|multi |
决定使用单线程还是多线程库。(对应文件中的BOOST_LIB_THREAD_OPT) |
runtime-link=static|shared |
决定是静态还是动态链接C/C++标准库。(对应文件中的BOOST_LIB_THREAD_OPT) |
--with-<library> |
只编译指定的库,如输入--with-regex就只编译regex库了。 |
--show-libraries |
显示需要编译的库名称 |
bjam.exe --toolset=msvc-10.0 --with-date_time runtimelink=static link=static stage
意思是要生静态库,该静态库静态链接C运行时库
生成的文件名字是:libboost_date_time-vc100-mt-sgd-1_48.lib(debug version),libboost_date_time-vc100-mt-s-1_48.lib(release version) 两个文件.
bjam.exe --toolset=msvc-10.0 --with-date_time runtimelink=shared link=static stage
意思是要生静态库,该静态库动态链接C运行时库
生成的文件名字是:libboost_date_time-vc100-mt-gd-1_48.lib(debug verion),libboost_date_time-vc100-mt-1_48.lib(release version) 两个文件.
bjam.exe --toolset=msvc-10.0 --with-date_time runtimelink=shared link=shared stage
意思是要生动态库,该动态库动态链接C运行时库
生成的文件名字是:boost_date_time-vc100-mt-gd-1_48.lib(debug version),boost_date_time-vc100-mt-1_48.lib(release version) 两个文件.
生成的dll名字是:boost_date_time-vc100-mt-gd-1_48.dll(debug version),boost_date_time-vc100-mt-1_48.dll(release version)
编译选项方面还有install等参数.
boost库生成文件命名和编译的更多相关文章
- (九)boost库之文件处理filesystem
(九)boost库之文件处理filesystem filesystem库是一个可移植的文件系统操作库,它在底层做了大量的工作,使用POSIX标准表示文件系统的路径,使C++具有了类似脚本语言的功能 ...
- 使用boost库生成 随机数 随机字符串
#include <iostream> #include <boost/random/random_device.hpp> #include "boost/rando ...
- boost库在windows下的编译和使用
因为跨平台的原因,现在要使用到boost库,boost库非常大,现在处于摸索阶段. 首先来说boost库在window下的安装和使用. 一.下载 首先从boost官方主页http://www.boos ...
- 使用boost库获取文件夹下所有文件名字
最近整理项目发现一个曾经找了好久的有用的代码片段,就是获取文件夹下所有文件的名字,和当前文件的绝对路径. 记录一下. 使用的是boost库, #include <boost/filesystem ...
- c++使用boost库遍历文件夹
1.只在当前目录下遍历 #include <boost/filesystem.hpp> string targetPath="/home/test/target"; b ...
- Boost库编译后命名方式
Boost官网的<Geting Started On Windows>(http://www.boost.org/doc/libs/1_38_0/more/getting_started/ ...
- windows下编译和安装boost库
boost是一个功能强大.构造精巧.跨平台.开源并且完全免费的C++程序库. 获取方式 boost提供源码形式的安装包,可以从boost官方网站下载,目前最新版本是1.59.0. 本机上正好有boos ...
- Boost库编译安装
一.Boost库介绍 Boost库是一个经过千锤百炼.可移植.提供源代码的C++库,作为标准库的后备,是C++标准化进程的发动机之一.Boost库由C++标准委员会库工作组成员发起,其 ...
- vs配置boost库
步骤: 1.在boost官网下载boost版本,以1.59.0为例. 2.解压,解压后可看到文件夹下有个bootstrap.bat文件. 注意: 如果有以下error: 'cl' 不是内部或外部命令, ...
随机推荐
- python中struct.pack()函数和struct.unpack()函数
python中的struct主要是用来处理C结构数据的,读入时先转换为Python的字符串类型,然后再转换为Python的结构化类型,比如元组(tuple)啥的~.一般输入的渠道来源于文件或者网络的二 ...
- eclipse安装python开发pydev插件
eclipse安装python开发pydev插件 下载eclipse的python开发插件pydev http://pan.baidu.com/s/1qXHt8pI 下载python.exe,并安装. ...
- Python语言之函数
1.函数的定义与调用 def function(x): print("function(%s)"%x) function("hello") #call the ...
- 11-c++虚拟函数
虚拟函数 #include "stdio.h" class A{ public: void print() { printf("%s","this i ...
- 关于Python中的类普通继承与super函数继承
关于Python中的类普通继承与super函数继承 1.super只能用于新式类 2.多重继承super可以保公共父类仅被执行一次 一.首先看下普通继承的写法 二.再看看super继承的写法 参考链接 ...
- unable to get system library for the project
当向eclipse导入项目实例后,项目上出现红叉的错误提示,在项目属性里的Java Build Path里发现了错误提示复选选项: unable to get system library for t ...
- Python 之selenium+phantomJS斗鱼抓取案例
from selenium import webdriver from bs4 import BeautifulSoup import time if __name__ == '__main__': ...
- JavaScript day3(运算符)
运算符(operator) 基本运算符: 算术运算符用于执行变量之间的算术运算,给定 y=5: 运算符 描述 例子 结果 + 加 x=y+2 x=7 - 减 x=y-2 x=3 * 乘 x=y*2 x ...
- JavaScript:一句代码输出重复字符串(字符串乘法)
看到一个题目要求写一个函数times,输出str重复num次的字符串. 比如str:bac num:3 输出:abcabcabc 除了利用循环还有几种方法,我学习研究之后记下以下三种方法. 1 ...
- P2386 放苹果
题目背景 (poj1664) 题目描述 把M个同样的苹果放在N个同样的盘子里,允许有的盘子空着不放,问共有多少种不同的分发(5,1,1和1,1,5是同一种方法) 输入输出格式 输入格式: 第一行是测试 ...