c++windowsboostboost-build

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


I'm looking a simple setup for the config.jam which will build Boost (1.60 or later) for both x86 and x64 on Windows using MSVC. Ideally using a single call to b2 -- I know that it's supposed to support generating multiple outputs from a single call. Having two separate calls for x86 and x64 is ok but not preferred.

The other thing I would like is to have it output both sets of libraries into the same folder. Obviously then they need to have different names, so I would like it to put -x64 somewhere in the names of the x64 binaries. And it still needs to auto-link, so I can't just rename them manually, it has to be something that the build system supports. This part is essential.

I've read that b2 provides a --buildid parameter and the auto-link supports a BOOST_LIB_BUILDID define which permits insertion of a custom keyword like this, but I'm not sure exactly how to use them. Is it possible to specify two builds in the config.jam, one with a buildid and one without (and run them both with a single call to b2), or does this really require two separate calls?

Does anyone know the magic words?


Solution

  • 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.)