boost 1.341编译 by visual studio 2008

boost 1.341并不支持vs 2008,因此需要修改如下几个文件。

msvc.jam

{
# Even if version is not explicitly specified, try to detect the version
# from the path.
+ if [ MATCH “(Microsoft Visual Studio 9.0)” : $(command) ]
+ {
+ version = 9.0 ;
+ }
if [ MATCH “(Microsoft Visual Studio 8)” : $(command) ]
{
version = 8.0 ;

.ProgramFiles = [ path.make [ common.get-program-files-dir ] ] ;
-.known-versions = 8.0 8.0express 7.1 7.1toolkit 7.0 6.0 ;
+.known-versions = 9.0 9.0express 8.0 8.0express 7.1 7.1toolkit 7.0 6.0 ;
# Version aliases
.version-alias-6 = 6.0 ;
.version-alias-6.5 = 6.0 ;
.version-alias-7 = 7.0 ;
.version-alias-8 = 8.0 ;
+.version-alias-9 = 9.0 ;
# Name of the registry key that contains Visual C++ installation path
# (relative to “HKEY_LOCAL_MACHINE\SOFTWARE\\Microsoft”

.version-7.1-reg = “VisualStudio\\7.1\\Setup\\VC” ;
.version-8.0-reg = “VisualStudio\\8.0\\Setup\\VC” ;
.version-8.0express-reg = “VCExpress\\8.0\\Setup\\VC” ;
+.version-9.0-reg = “VisualStudio\\9.0\\Setup\\VC” ;
+.version-9.0express-reg = “VCExpress\\9.0\\Setup\\VC” ;
# Visual C++ Toolkit 2003 do not store its installation path in the registry.
# The environment variable ‘VCToolkitInstallDir’ and the default installation

auto_link.hpp

// vc71:
# define BOOST_LIB_TOOLSET “vc71″
-#elif defined(BOOST_MSVC) && (BOOST_MSVC >= 1400)
+#elif defined(BOOST_MSVC) && (BOOST_MSVC == 1400)
// vc80:
# define BOOST_LIB_TOOLSET “vc80″
+#elif defined(BOOST_MSVC) && (BOOST_MSVC >= 1500)
+
+ // vc90:
+# define BOOST_LIB_TOOLSET “vc90″
+
#elif defined(__BORLANDC__)

visualc.hpp

#error “Compiler not supported or configured - please reconfigure”
#endif
//
-// last known and checked version is 1400 (VC8):
-#if (_MSC_VER > 1400)
+// last known and checked version is 1500 (VC9):
+#if (_MSC_VER > 1500)
# if defined(BOOST_ASSERT_CONFIG)
# error “Unknown compiler version - please run the configure tests and report the results”
# else

named_slot_map.hpp

|| slot_ == other.slot_));

}

-#if BOOST_WORKAROUND(_MSC_VER, <= 1400)

+#if BOOST_WORKAROUND(_MSC_VER, <= 1500)

void decrement();

void advance(difference_type);

#endif

named_slot_map.cpp

typedef slot_container_type::const_iterator const_group_iterator;

-#if BOOST_WORKAROUND(_MSC_VER, <= 1400)

+#if BOOST_WORKAROUND(_MSC_VER, <= 1500)

void named_slot_map_iterator::decrement() { assert(false); }

void named_slot_map_iterator::advance(difference_type) { assert(false); }

#endif

 

编译命令

M:\boost_1_34_1>bjam -a -sICU_PATH=m:\icu4c-3_8-src\icu_x86_9 –wi

thout-python –toolset=msvc-9.0 –prefix=m:\boost86 install

M:\boost_1_34_1>bjam -a -sICU_PATH=m:\icu4c-3_8-src\icu_x64_9 –wi

thout-python –toolset=msvc-9.0 address-model=64 –prefix=m:\boost64 install

要注意的是,icu库本身用了msvc的库,因此要用vs2008重新编译icu库。此外,header是一样的,lib名字不同,因此可以拷贝到boost\lib_x86/64的lib目录下。

注意icu的实现很差劲,用的名字都相同,所以必须把编译结果的dll拷贝到不同的目录下才行。

最后的目录为:

boost——-include———boost-1_34_1————boost———algorithm…

                    lib_x64———-icu_8

                                               icu_9

                                               boost_data_time-vc80-mt.lib

                                               boost_data_time-vc90-mt.lib

                    lib_x86———-icu_8

                                               icu_9

                                               xxxxxx.lib/dll

为了确保的确link的是vs2008的runtime lib,可以用depend.exe看一下所生成的dll。