在Windows上将32位和64位的Boost构建到同一文件夹中 [英] Building Boost for 32-bit and 64-bit on Windows into the same folder
问题描述
我正在寻找config.jam的简单设置,它将使用MSVC在Windows上为x86和x64构建Boost(1.60或更高版本).理想情况下,使用一次对b2的调用-我知道它应该支持通过一次调用生成多个输出.可以分别对x86和x64进行两次调用,但这不是首选.
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.
我想做的另一件事是将两套库都输出到相同文件夹中.显然,他们需要使用不同的名称,因此我希望将-x64
放在x64二进制文件的名称中.而且它仍然需要自动链接,因此我不能只是手动对其重命名,它必须是构建系统支持的内容.这部分是必不可少的.
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.
我已经阅读,b2提供了--buildid
参数,并且自动链接支持 BOOST_LIB_BUILDID
定义允许插入这样的自定义关键字,但是我不确定如何使用它们.是否可以在config.jam中指定两个版本,一个带有buildid,另一个不带(并通过一次调用b2来运行它们),或者这真的需要两个单独的调用吗?
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?
有人知道魔语吗?
推荐答案
我想那不是人们要做的事情.
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
这会将x86和x64库都放入stage\lib
;对于实际编译应用程序,仅需要此文件夹和boost
文件夹的内容.然后,在构建软件时,将此片段添加到项目文件中(通过props文件):
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
在技术上是可选的,但是如果您要编译在其导出的API中具有Boost类型的DLL,则有助于提高兼容性.您仍然需要确保它们都使用相同的编译器和Boost版本进行编译,虽然.)
(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.)
这篇关于在Windows上将32位和64位的Boost构建到同一文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!