macos 将编译器标志传递给需要编译的 boost 库(例如 Thread)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6945012/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
passing compiler flags to boost libraries (such as Thread) which require compilation
提问by eeeeaaii
So I know that the boost libraries are primarily header-only but there are a few which require compilation, for example Boost.Thread. In Darwin, how do I compile these and pass the -m32 flag so they can be compiled into a 32-bit (i386) binary? There's this Jamroot thing which I've never heard of and I am not sure at all where to start.
所以我知道 boost 库主要是头文件,但有一些需要编译,例如 Boost.Thread。在 Darwin 中,如何编译这些并传递 -m32 标志,以便将它们编译为 32 位(i386)二进制文件?我从未听说过 Jamroot 这个东西,我完全不知道从哪里开始。
Clarification: I'm not asking how to compile a program with -m32 flag and use the boost libraries. I'm asking how to compile the Boost libraries themselves with the -m32 flag.
澄清:我不是在问如何使用 -m32 标志编译程序并使用 boost 库。我在问如何使用 -m32 标志自己编译 Boost 库。
采纳答案by ildjarn
To specify what architecture to compile for, specify the architecture
feature when invoking b2.
要指定要编译的体系结构,请architecture
在调用 b2 时指定功能。
To specify compiler options that don't already have built-in features, specify the cxxflags
feature when invoking b2.
要指定尚未具有内置功能的编译器选项,请cxxflags
在调用 b2 时指定该功能。
To specify linker options that don't already have built-in features, specify the linkflags
feature when invoking b2.
要指定尚未具有内置功能的链接器选项,请linkflags
在调用 b2 时指定该功能。
All of these are listed in the Boost.Build docs.
所有这些都列在Boost.Build 文档中。
回答by RMWChaos
From what I understand, and if I read the documentation correctly, the way to build a particular architecture of boost is with the "address-model=xx" option for b2.
据我了解,如果我正确阅读了文档,构建特定 boost 架构的方法是使用 b2 的“address-model=xx”选项。
EXAMPLES:
例子:
b2 install toolSET=msvc-9.0 link=shared variant=release address-model=64
or
或者
b2 install toolSET=msvc-9.0 link=shared variant=release address-model=32
Hope that helps.
希望有帮助。
Regards,
问候,
-RMWChaos
-RMWChaos
EDIT: Found another SO Thread providing the same answer here.
编辑:发现另一个 SO Thread 在此处提供相同的答案。