VC编程之Boost1.61+win7+VC2015编译
小标 2018-09-04 来源 : 阅读 1543 评论 0

摘要:本文主要向大家介绍了VC编程之Boost1.61+win7+VC2015编译,通过具体的内容向大家展示,希望对大家学习VC编程有所帮助。

本文主要向大家介绍了VC编程之Boost1.61+win7+VC2015编译,通过具体的内容向大家展示,希望对大家学习VC编程有所帮助。

下载

通过boost官方网站, 或直接在source forge下载boost_1_6x_0. 

可选包

Zlib library, 环境变量: ZLIB_SOURCE

bzip2, 环境变量: BZIP2_SOURCE

ICU i18n, 环境变量HAVE_ICU=1, ICU_PATH

expat, 环境变量: EXPAT_INCLUDE (头文件包含目录) 和 EXPAT_LIBPATH (库目录)

在Windows上编译Boost

下载完Boost源文件压缩包后, 创建boost-src目录, 并把源文件解压到此目录. 假设你想把Boost安装到boost-dir目录, boost-build目录是中间临时文件. 在命令行执行下面的步骤:

编译器的选择(x86_amd64, amd64等的区别)(注:2)

32/64 位系统编译在32位系统上运行 => x86

32 系统上编译64位系统上运行 => x86_amd64

64 系统上编译在64位系统上运行 => amd64

1.初始化VC编译环境:

32位系统上, 初始化32位VC编译环境:

    "C:\Program Files\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86

32位系统上, 要生成64位的boost库, 初始化64位VC++编译环境:

     "C:\Program Files\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64

64位操作系统上, 安装的32位Visual Studio, Visual Studio 一般安装在 C:\Program Files (x86):

    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86

64位操作系统上, 安装的32位Visual Studio, 生成64位库:

    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64

2. 生成Boost编译系统:

  cd /d drive:\path\to\boost-src
  bootstrap.bat

3. 解压bzip2和zlib源压缩包, 备注解压的目录.

4. 编译和安装:

32位库

  b2 install --libdir=boost-dir\libs --includedir= boost-dir\include --build-dir=boost-build --layout=tagged variant=debug,release threading=multi link=shared runtime-link=shared -sZLIB_SOURCE=<zlib-src-dir> -sBZIP2_SOURCE=<bzip2-src-dir>

 64位库

  b2 install --libdir=boost-dir\libs64 --includedir= boostdir\include --build-dir=boost-build64 --layout=tagged variant=debug,release threading=multi link=shared runtime-link=shared address-model=64 –sZLIB_SOURCE=<zlib-src-dir> -sBZIP2_SOURCE=<bzip2-src-dir>

我的实例:

"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
cd /d F:\Develop\Libs\boost_1_6x_0
bootstrap.bat

1. 编译和安装32位库:
b2 install --libdir=G:\yy\build\libs --includedir=G:\yy\build\include --build-dir=boost-build --layout=tagged variant=debug,release threading=multi link=shared runtime-link=shared

2. 编译和安装64位库:
b2 install --libdir=G:\yy\build\libs64 --includedir=G:\yy\build\include --build-dir=boost-build64--layout=tagged variant=debug,release threading=multi link=shared runtime-link=shared address-model=64 architecture=x86 

3. 编译和安装64位库(方式2):

b2 install --prefix=F:\Develop\bin\x64\boost-1_62 --build-dir=boost-build64 --layout=tagged variant=debug,release threading=multi link=shared runtime-link=shared address-model=64 architecture=x86 --with-thread --with-graph --with-date_time

4. 编译和安装64位库(2017-3-2 1.63):

  b2 install --prefix=F:\Develop\bin\x64\boost-1_63 --build-dir=F:\Develop\build\VC14\boost-1_63-build64 address-model=64 architecture=x86 --with-thread 
 默认值:
  --build-type=minimal   在Windows上, 生成基于共享运行库的debug和release静态多线程库
  --layout=versioned    在Windows上默认,Boost二进制文件名称包括Boost版本号、编译器名称和版本和编码生成属性。
                  Boost头文件安装在<HDRDIR>子目录 <HDRDIR>的名字包含Boost版本号。 

5. 编译和安装64位库(boost.python)(2017-3-18 1.63):

 b2 install --prefix=D:\Develop\bin\vc14\x64\boost-1_63 --build-dir=D:\Develop\build\vc14\boost-1_63-build64 address-model=64 architecture=x86 toolset=msvc-14.0 --with-python link=shared

 

Boost的自动链接功能:

 

Boost默认启用自动链接功能, 建议采用关闭自动链接功能。
  在附加预定义宏 加 BOOST_ALL_NO_LIB ,这样就关闭了BOOST的自动链接LIB的功能。然后把需要的lib库在附加库里手动加入。

修订:

1. 2016-11-09: 64位编译需要加入CPU架构参数: architecture=x86
2. 2016-11-23: 编译器的选择(x86_amd64, amd64等的区别), 内容进行了整理, boost更新到1.62.0
3. 2017-03-02: 使用默认参数编译, boost更新到1.63.0
4. 2017-04-15: 建议关闭boost自动链接功能

本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标编程语言VC/MFC频道!

本文由 @小标 发布于职坐标。未经许可,禁止转载。
喜欢 | 0 不喜欢 | 0
看完这篇文章有何感觉?已经有0人表态,0%的人喜欢 快给朋友分享吧~
评论(0)
后参与评论

您输入的评论内容中包含违禁敏感词

我知道了

助您圆梦职场 匹配合适岗位
验证码手机号,获得海同独家IT培训资料
选择就业方向:
人工智能物联网
大数据开发/分析
人工智能Python
Java全栈开发
WEB前端+H5

请输入正确的手机号码

请输入正确的验证码

获取验证码

您今天的短信下发次数太多了,明天再试试吧!

提交

我们会在第一时间安排职业规划师联系您!

您也可以联系我们的职业规划师咨询:

小职老师的微信号:z_zhizuobiao
小职老师的微信号:z_zhizuobiao

版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
 沪公网安备 31011502005948号    

©2015 www.zhizuobiao.com All Rights Reserved

208小时内训课程