vs 2008 编译boost 1.35.0
boost 1.35.0已经内置了1.34.1为让vs2008编译所需要修改的内容。所以不再需要手工修改。虽然boost 1.35.0文档中说目前不支持vs2008,以后会支持。但是经过一番折腾,发现实际上可以编译。
例如:
M:"CODE"VNN4"OUTER"boost_1_35_0>bjam -a -sICU_PATH=m:"icu4c-3_8-src"icu_x86_9 — without-python –without-mpi –without-regex –toolset=msvc-9.0 –build-type=complete –prefix=m :"boost86 install
M:"CODE"VNN4"OUTER"boost_1_35_0>bjam -a -sICU_PATH=m:"icu4c-3_8-src"icu_x64_9 — without-python –without-mpi –without-regex –toolset=msvc-9.0 –build-type=complete address-model=64 –prefix=m :"boost64 install
需要注意的是,build-type=complete很重要,否则没有debug版本,没法调试进入boost库。
尽量应该使用vc2008 start菜单中的Visual Studio 2008 Command Prompt来进行编译。64位版本则应该使用vs2008 start菜单中的Visual Studio 2008 x64 Win64 Command Prompt来进行编译。似乎普通cmd也可以,但是为保险起见,建议还是用vc菜单中的cmd。
注意1.35.0中regex库似乎有些问题,这个库如果不指定-sICU_PATH,则可以用build-type=complete,如果指定 -sICU_PATH,不指定build-type=complete也可以。x86和x64都没问题。但是如果同时指定-sICU_PATH和 –build-type=complete则会有问题。
M:"CODE"VNN4"OUTER"boost_1_35_0>bjam -a -sICU_PATH=m:"icu4c-3_8-src"icu_x86_9 — without-python –without-mpi –toolset=msvc-9.0 –build-type=complete –prefix=m :"boost86 install warning: Graph library does not contain optional GraphML reader. note: to enable GraphML support, set EXPAT_INCLUDE and EXPAT_LIBPATH to the note: directories containing the Expat headers and libraries, respectively. Building Boost.Regex with Unicode/ICU support enabled Using ICU in m:"icu4c-3_8-src"icu_x86_9/include Skipping build of: ./install <build>no in common properties Skipping build of: ./install <build>no in common properties Skipping build of: ./install <build>no in common properties Skipping build of: ./install <build>no in common properties Skipping build of: libs/regex/build/icucore <build>no in common properties Skipping build of: libs/regex/build/icuin <build>no in common properties Skipping build of: libs/regex/build/icudata <build>no in common properties M:/CODE/VNN4/OUTER/boost_1_35_0/tools/build/v2/kernel"class.jam:93: in new *** argument error * rule object(searched-lib-target)@54887.__init__ ( name : project : shared ? : search * : action ) * called with: ( icudt icuin icuuc : object(project-target)@158 : true : /m:/icu 4c-3_8-src/icu_x86_9/lib : object(null-action)@54886 : : : : ) * extra argument icuin M:/CODE/VNN4/OUTER/boost_1_35_0/tools/build/v2/tools"builtin.jam:349:see definit ion of rule ‘__init__’ being called M:/CODE/VNN4/OUTER/boost_1_35_0/tools/build/v2/tools"builtin.jam:592: in object( searched-lib-generator)@6.run M:/CODE/VNN4/OUTER/boost_1_35_0/tools/build/v2/build"generators.jam:859: in try- one-generator-really M:/CODE/VNN4/OUTER/boost_1_35_0/tools/build/v2/build"generators.jam:920: in try- one-generator M:/CODE/VNN4/OUTER/boost_1_35_0/tools/build/v2/build"generators.jam:1131: in con struct-really M:/CODE/VNN4/OUTER/boost_1_35_0/tools/build/v2/build"generators.jam:1204: in gen erators.construct M:/CODE/VNN4/OUTER/boost_1_35_0/tools/build/v2/tools"builtin.jam:496: in object( lib-generator)@5.run M:/CODE/VNN4/OUTER/boost_1_35_0/tools/build/v2/build"generators.jam:859: in try- one-generator-really M:/CODE/VNN4/OUTER/boost_1_35_0/tools/build/v2/build"generators.jam:920: in try- one-generator M:/CODE/VNN4/OUTER/boost_1_35_0/tools/build/v2/build"generators.jam:1131: in con struct-really M:/CODE/VNN4/OUTER/boost_1_35_0/tools/build/v2/build"generators.jam:1204: in gen erators.construct M:/CODE/VNN4/OUTER/boost_1_35_0/tools/build/v2/build"targets.jam:1368: in constr uct M:/CODE/VNN4/OUTER/boost_1_35_0/tools/build/v2/build"targets. M:"CODE"VNN4"OUTER"boost_1_35_0>
怀疑是因为icu库本身的sln和prj文件中并没有static link的选项。
最后采用如下方法解决:
如果是x64
bjam -a -sICU_PATH=m:"icu4c-3_8-src"icu_x64_9 –with-regex –toolset-msvc address-model=64 release
bjam -a -sICU_PATH=m:"icu4c-3_8-src"icu_x64_9 –with-regex –toolset-msvc address-model=64 debug
bjam -a -sICU_PATH=m:"icu4c-3_8-src"icu_x64_9 –with-regex –toolset=msvc msvc/link=static address-model=64 debug
bjam -a -sICU_PATH=m:"icu4c-3_8-src"icu_x64_9 –with-regex –toolset=msvc msvc/link=static address-model=64 release
如果是x86
bjam -a -sICU_PATH=m:"icu4c-3_8-src"icu_x86_9 –with-regex –toolset-msvc release
bjam -a -sICU_PATH=m:"icu4c-3_8-src"icu_x86_9 –with-regex –toolset-msvc debug
bjam -a -sICU_PATH=m:"icu4c-3_8-src"icu_x86_9 –with-regex –toolset=msvc msvc/link=static debug
bjam -a -sICU_PATH=m:"icu4c-3_8-src"icu_x86_9 –with-regex –toolset=msvc msvc/link=static release
没有编译static link c++ runtime lib的static lib,只编译了动态link c++ runtime lib的dll以及static lib
注意编译完之后的dll,lib以及libxxx.lib拷贝到目录下时,要同时去掉1_35拷贝一份,因为boost头文件中通过prgram(link)进行的auto link指向的lib不包含1_35后缀
附注:
bjam还有其他一些选项,例如
bjam –toolset=msvc msvc/architecture=x86/address-model=64/runtime-link=shared/link=shared debug stage