在使用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
- 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.lib libboost_chrono-vc120-mt-gd-1_55.lib 使用runtime-link=static選項編譯出來的結果如: libboost_chrono-vc120-mt-s-1_55.lib libboost_chrono-vc120-mt-s-gd-1_55.lib 編譯結果不同后綴的含義: mt : Multi threading s: Static gd: 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:
編譯debug/release版本。一般都是程序的debug版本對應庫的debug版本,所以兩個都編譯。