Building Boost for 32-bit and 64-bit on Windows into the same folder

心已入冬 提交于 2019-12-05 18:48:28

I guess that's just not a thing people do, then.

I've settled for just running the command twice; for the record my working incantation was this:

bootstrap
b2 -j8 --build-dir=build               toolset=msvc-14.0 variant=debug,release link=shared threading=multi runtime-link=shared                  stage
b2 -j8 --build-dir=build --buildid=x64 toolset=msvc-14.0 variant=debug,release link=shared threading=multi runtime-link=shared address-model=64 stage

This puts both x86 and x64 libraries into stage\lib; for actually compiling applications only the contents of this folder and the boost folder are required. Then when building the software this snippet is added to project files (via a props file):

<PropertyGroup>
    <BoostIncludeDir>path\to\include\boost\</BoostIncludeDir>
    <BoostLibDir>path\to\lib\</BoostLibDir>
</PropertyGroup>
<ItemDefinitionGroup>
  <ClCompile>
    <AdditionalIncludeDirectories>$(BoostIncludeDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
    <PreprocessorDefinitions>BOOST_ALL_DYN_LINK;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    <PreprocessorDefinitions Condition="'$(Platform)'=='x64'">BOOST_LIB_BUILDID=x64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  </ClCompile>
  <Link>
      <AdditionalLibraryDirectories>$(BoostLibDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
  </Link>
</ItemDefinitionGroup>

(BOOST_ALL_DYN_LINK is technically optional, but it helps improve compatibility if you are compiling DLLs that have Boost types in their exported API. You still need to make sure that they're all compiled with the same compiler and Boost versions, though.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!