VS编译BOOST,bjam参数详解

这篇具有很好参考价值的文章主要介绍了VS编译BOOST,bjam参数详解。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

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= Install architecture independent files here.

                 Default; C:\Boost on Win32

                 Default; /usr/local on Unix. Linux, etc.

–exec-prefix= Install architecture dependent files here.

                 Default; <PREFIX>

–libdir=

Install library files here.
                 Default; <EPREFIX>/lib

–includedir= 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= 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= 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- Build and install the specified

                        If this option is used, only libraries

                        specified using this option will be built.

–without- 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个, 理论上应该有 222*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”文章来源地址https://www.toymoban.com/news/detail-470739.html

到了这里,关于VS编译BOOST,bjam参数详解的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • windows如何编译各种版本boost库

    –without:选择不编译某个库 –toolset:指定编译工具 –stagedir:指定生成库所在位置,默认位置stage/lib libboost_filesystem-vc142-mt-s-x64-1_70.lib 静态库,静态链接,release模式,多线程模式, 64位库 libboost_filesystem-vc142-mt-sgd-x64-1_70.lib 静态库,静态链接,debug模式,多线程模式, 64位库

    2023年04月14日
    浏览(31)
  • linux下boost编译arm版本

    1.下载 https://www.boost.org/users/history/version_1_74_0.html 2.解压 2.编译 3 替换gcc 修改配置文件project-config.jam,将下列的arm gcc编译器替换为你本机的编译器,比如我是用S32G的编译器 编译 ./b2 5.安装

    2024年01月23日
    浏览(34)
  • elasticsearch ES搜索权重设置(boost参数)

    摘要:7.Elasticsearch boost的搜索条件权重_lm324114的专栏-CSDN博客_boost es 摘要2:elasticsearch boost - 简书 摘要3:Elasticsearch 10 Boost(提升权重) - 简书

    2024年02月12日
    浏览(26)
  • Boost电路实战详解!(高效率同步整流,PID闭环追踪)

    提示:若想实战演练,请先熟悉文章操作流程哦,不然会有危险!! 我建了一个群,分享我个人做项目的经历和资源,纯个人爱好,一切免费,看自己空闲时间答疑,有想法的可以加QQ群280730348 大家好!鸽了两个月的电路博主回归啦,这段时间一直在忙研究生开学的事儿,也

    2024年02月03日
    浏览(36)
  • ubuntu上安装boost库为SOMEIP的X86和ARM下编译做准备(编译两种版本)

    Boost库是C++拓展库,是SOMEIP源码编译所必需的库。编译 Boost 库时,需要根据不同的架构,选择不同的工具链和参数 首先,Boost源码下载,Boost官网:https://www.boost.org 基于此处我编译的SOMEIP源码版本,需要安装1.74版本的Boost库,下载链接:https://boostorg.jfrog.io/artifactory/main/relea

    2024年02月10日
    浏览(33)
  • 【Boost2】Boost电路的电感选型

    在Buck电路的输出电感的分析过程中,我们已经提到了电感的保持电流不突变的特性。 1.电感电流变化规律 假设电流流经电感,但是电感的磁场不变化,电感就不会产生阻碍电流变化的感生电动势,电感在直流电路中就相当于一根导线,导线本身的电阻值很小,因此它对电流

    2024年02月13日
    浏览(25)
  • BUCK、BOOST、BUCK-BOOST电路原理分析

    DC-DC DC-DC电源,即直流-直流变换器,是指将一个固定的直流电压变换为可变的直流电压,也称为直流斩波器。DC-DC有多种拓扑结构,如BUCK(降压)、BOOST(升压)、BUCK-BOOST(升降压)三大基本拓扑结构。 斩波器的工作方式有两种,一是PWM波“定频调宽”,即脉宽调制方式Ts不

    2024年02月03日
    浏览(92)
  • Boost搜索引擎项目

    目录 1.项目相关背景 2.搜索引擎的相关宏观原理 3.搜索引擎技术栈和项目环境 4.正排索引 倒排索引--搜索引擎原理 5.编写数据去标签与数据清洗的模块 -- parser.hpp 去标签 编写parser(将文件去标签) 编写EnumFile函数 编写ParseFile函数 解析三大部分: 编写SaveFile函数 6.建立索引--编写

    2024年02月01日
    浏览(71)
  • 【项目】Boost搜索引擎

    研发搜索引擎的公司,如百度、搜狗、360搜索,还有各大网站各种客户端也提供搜索功能 为什么选择实现Boost搜索引擎 1)因为Boost官方网站是没有搜索功能的,所以我们可以为Boost实现一个站内搜索引擎,虽然官方提供了boost相关的一些方法,标准库中的一些接口,但是我们想看到

    2024年02月03日
    浏览(38)
  • boost 搜索引擎

    done 公司:百度、搜狗、360搜索、头条新闻客户端 - 我们自己实现是不可能的! 站内搜索:搜索的数据更垂直,数据量其实更小 boost的官网是没有站内搜索的,需要我们自己做一个 首先在用户进行搜索之前,在公司的服务器server上,内存上有一个searcher服务,而我们想进行搜

    2024年02月11日
    浏览(38)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包