vs2013编译boost库

来源:互联网 发布:linux安装压缩软件 编辑:程序博客网 时间:2024/04/29 23:43
  • 32位编译:

1.打开一个命令行,进入boost所在目录,运行bootstrap.bat

2.编译命令:

bjam.exe stage --toolset=msvc-12.0 --without-graph --without-graph_parallel --without-math --without-mpi --without-serialization --without-wave --without-atomic --without-chrono --without-random --without-regex --without-test --without-thread --without-program_options --without-serialization --without-signals --stagedir=".\bin\vc12_x86" link=static runtime-link=shared threading=multi debug release 

  • 64位编译:

x64环境下编译得先从开始菜单启动Visual Studio 2013的vs2013 x64兼容工具命令行,而不是随便打开任意一个命令行窗口就行。然后转到boost根文件夹,运行bootstrap.bat生成x64版的bjam.exe。然后运行命令:   
bjam.exe stage --toolset=msvc-12.0 --without-graph --without-graph_parallel --without-math --without-mpi --without-serialization --without-wave --without-atomic --without-chrono --without-random --without-regex --without-test --without-thread --without-program_options --without-serialization --without-signals --stagedir=".\bin\vc12_x64" link=static runtime-link=shared threading=multi debug release address-model=64   

复制代码
使用runtime-link=shared选项编译出来的结果如:libboost_chrono-vc120-mt-1_55.liblibboost_chrono-vc120-mt-gd-1_55.lib使用runtime-link=static选项编译出来的结果如:libboost_chrono-vc120-mt-s-1_55.liblibboost_chrono-vc120-mt-s-gd-1_55.lib编译结果不同后缀的含义:mt : Multi threadings: Staticgd: ABI with debug version
复制代码

 

  • 命令行选项解释:

stage/install:

stage表示只生成库(dll和lib),install还会生成包含头文件的include目录。本人推荐使用stage。

toolset:

指定编译器,可选的如borland、gcc、msvc(VC6)、msvc-12.0(VS2013)等。
without/with:

选择不编译/编译哪些库。因为mpi等库我都用不着,所以排除之。另外,wave、graph、math、regex、test、program_options、serialization、signals这几个库编出的静态lib都非常大,所以不需要的也可以without掉。这可以根据各人需要选择,默认是全部编译。但是需要注意,如果选择编译python的话,是需要python语言支持的,应该到python官方主页http://www.python.org/下载安装。
stagedir/prefix

stage时使用stagedir,install时使用prefix,表示编译生成文件的路径。

link:

生成动态链接库/静态链接库。生成动态链接库需使用shared方式,生成静态链接库需使用static方式。一般boost库可能都是以static方式编译,因为最终发布程序带着boost的dll感觉会比较累赘。
runtime-link:

动态/静态链接C/C++运行时库。同样有shared和static两种方式,这样runtime-link和link一共可以产生4种组合方式,各人可以根据自己的需要选择编译。一般link只选static的话,只需要编译2种组合即可,即link=static runtime-link=shared和link=static runtime-link=static。
threading:

单/多线程编译。一般都写多线程程序,当然要指定multi方式了;如果需要编写单线程程序,那么还需要编译单线程库,可以使用single方式。
debug/release:

0 0
原创粉丝点击