在使用vs2013编译boost-1.55.0之前,先要给boost打个补丁,补丁如下(可直接该源文件):
1 Index: has_member_function_callable_with.hpp 2 3 =================================================================== 4 5 --- has_member_function_callable_with.hpp (revision 86605) 6 7 +++ has_member_function_callable_with.hpp (working copy) 8 9 @@ -219,10 +219,17 @@ 10 11 struct BOOST_PP_CAT(BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME),_impl) 12 <Fun, true> 13 { 14 - template<class U> 15 - static BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) 16 - <U> Test(BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)<U>*); 17 - 18 + #ifdef BOOST_MSVC 19 + template<class U> 20 + static decltype( boost::move_detail::declval<Fun>().BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME() 21 + , boost_intrusive_has_member_function_callable_with::yes_type()) 22 + Test(Fun*); 23 + #else 24 + template<class U> 25 + static BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) 26 + <U> Test(BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)<U>*); 27 + #endif 28 + 29 template <class U> 30 static boost_intrusive_has_member_function_callable_with::no_type Test(...); 31
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
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
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:
编译debug/release版本。一般都是程序的debug版本对应库的debug版本,所以两个都编译。
原文:http://www.cnblogs.com/run220/p/3551134.html