编译boost (boost_1_52_0)

来源:互联网 发布:一年级体测数据 编辑:程序博客网 时间:2024/06/02 03:45

写在最前:

老版本的boost编译可以参考以下:(其实boost的所有版本编译都差不多)

Boost_1_46_1编译: http://blog.csdn.net/great3779/article/details/6454663

Boost_1_47_0编译: http://blog.csdn.net/great3779/article/details/6654780

Boost_1_48_0编译: http://blog.csdn.net/great3779/article/details/6977922

Boost_1_49_0编译: http://blog.csdn.net/great3779/article/details/7310392


Boost社区早在2012年11月5日即发布了boost_1_52_0,但由于最近工作上比较忙,因此直到今天才有空将此最新版本的boost编译指南放上来(也是由于工作忙的关系,1_50_0和1_51_0的编译指南没有写)。1_49_0的编译脚本在1_52_0上是完全兼容的,同样能自动将boost编译成vs2008、vs2010的32位及64位版本。过程复述如下:

1. 至http://sourceforge.net/projects/boost/files/boost/1.52.0/下载boost_1_52_0.7z。(说点题外话,.7z是7zip下的一种通用压缩格式,具有比.rar和.zip更优秀的性能,并且还是开源的(可获取到所有源代码!),最近我也正在研读其源代码,其实现的string-like类(CStringBase)以及vector-like类(CBaseRecordVector)具有和STL相似的功能,且可读性更好。网址为 http://www.7-zip.org/ )

2. 解压至D:\boost_1_52_0\ (当然也可以是其他文件夹,仅作示例。)

3. 将批处理文件放在D:\boost_1_52_0\下。批处理文件可至http://download.csdn.net/detail/great3779/4104039免费下载。(也即附在最后的脚本)(如图)


4. 接下来,你只需要启动批处理,然后端一杯咖啡,等待脚本为你做完一切。完成后的效果如下图:


5. 最后,去设置你的编译器,开始使用最新版的boost吧。



附:批处理脚本:

[cpp] view plaincopy
  1. rem 创建者:黄志丹 great3779@sina.com 20130103


    rem @echo off


    rem 先编译bjam
    start bootstrap.bat


    rem 等待一分钟待bjam编译完成(如果电脑性能过差,可以设置等待时间更长一些)
    SET SLEEP=ping 127.0.0.1 -n
    %SLEEP% 60 > nul


    rem 利用bjam编译boost库
    rem 在此,我们编译vs2008和vs2010下的x86及x64共4类boost库文件


    rem 建立库文件夹
    rem vs2008 win32库文件夹
    md stage\lib\win32\vs9_0\


    rem vs2008 x64库文件夹
    md stage\lib\x64\vs9_0\


    rem vs2010 win32库文件夹
    md stage\lib\win32\vs10_0\


    rem vs2010 x64库文件夹
    md stage\lib\x64\vs10_0\


    rem ******************************************************************
    rem 先删除lib下所有文件(不删除文件夹)
    del stage\lib\*.* /Q


    rem 编译vs2008 win32库文件
    bjam --toolset=msvc-9.0 architecture=x86 --with-system --with-thread --with-date_time --with-filesystem --with-serialization


    rem 拷贝至\stage\lib\win32\vs9_0
    copy stage\lib\*.* stage\lib\win32\vs9_0\*.* /Y
    rem ##################################################################


    rem ******************************************************************
    rem 先删除lib下所有文件(不删除文件夹)
    del stage\lib\*.* /Q


    rem 编译vs2008 x64库文件
    bjam --toolset=msvc-9.0 architecture=x86 address-model=64 --with-system --with-thread --with-date_time --with-filesystem --with-serialization


    rem 拷贝至\stage\lib\x64\vs9_0
    copy stage\lib\*.* stage\lib\x64\vs9_0\*.* /Y
    rem ##################################################################


    rem ******************************************************************
    rem 先删除lib下所有文件(不删除文件夹)
    del stage\lib\*.* /Q


    rem 编译vs2010 win32库文件
    bjam --toolset=msvc-10.0 architecture=x86 --with-system --with-thread --with-date_time --with-filesystem --with-serialization


    rem 拷贝至\stage\lib\win32\vs10_0
    copy stage\lib\*.* stage\lib\win32\vs10_0\*.* /Y
    rem ##################################################################


    rem ******************************************************************
    rem 先删除lib下所有文件(不删除文件夹)
    del stage\lib\*.* /Q


    rem 编译vs2010 x64库文件
    bjam --toolset=msvc-10.0 architecture=x86 address-model=64 --with-system --with-thread --with-date_time --with-filesystem --with-serialization


    rem 拷贝至\stage\lib\x64\vs10_0
    copy stage\lib\*.* stage\lib\x64\vs10_0\*.* /Y
    rem ##################################################################


    rem 删除lib下所有文件(不删除文件夹)
    del stage\lib\*.* /Q


    rem boost_1_52_0共有21个库需要编译使用,分别是chrono, date_time, exception, filesystem, graph, graph_parallel, iostreams, locale, math, 
    rem mpi, program_options, python, random, regex, serialization, signals, system, test, thread, timer, wave。
    rem 我仅选用了自己常用的几个做以上编译示例,其他使用者可以根据自己的需求选择编译。全部编译boost大概需要1个小时以上(视机器性能)
    rem 全部编译boost的命令如下:bjam --toolset=msvc-9.0 --build-type=complete stage
原创粉丝点击