Boost1.6x+win7+VC2015编译

下载


通过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自动链接功能

转载于:https://www.cnblogs.com/yaoyu126/p/5547297.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值