C++ 您如何在 Windows 上构建 x64 Boost 库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/302208/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 14:26:55  来源:igfitidea点击:

How do you build the x64 Boost libraries on Windows?

c++visual-studio-2005boost64-bitboost-build

提问by Ferruccio

I've built the x86 Boost libraries many times, but I can't seem to build x64 libraries. I start the "Visual Studio 2005 x64 Cross Tools Command Prompt" and run my usual build:

我已经多次构建 x86 Boost 库,但我似乎无法构建 x64 库。我启动“Visual Studio 2005 x64 Cross Tools Command Prompt”并运行我通常的构建:

bjam --toolset=msvc --build-type=complete --build-dir=c:\build install

But it still produces x86 .lib files (I verified this with dumpbin /headers). What am I doing wrong?

但它仍然生成 x86 .lib 文件(我用 dumpbin /headers 验证了这一点)。我究竟做错了什么?

回答by macbirdie

You need to add the address-model=64parameter.

您需要添加address-model=64参数。

Look e.g. here.

这里

回答by Teemu Ikonen

The accepted answer is correct. Adding this in case somebody else googles this answer and still fails to produce x64 version.

接受的答案是正确的。添加这个以防其他人在谷歌上搜索这个答案但仍然无法生成 x64 版本。

Following is what I had to do to build Boost 1.63 on Visual Studio 15 2017 Community Edition.

以下是我在 Visual Studio 15 2017 Community Edition 上构建 Boost 1.63 必须做的事情。

Commands executed from VS environment cmd shell. Tools -> Visual Studio Command Prompt

从 VS 环境 cmd shell 执行的命令。工具 -> Visual Studio 命令提示符

C:\Work\Boost_1_63> C:\Program Files (x86)\Microsoft Visual Studio17\Community\VC\Auxiliary\Build\vcvarsall.bat amd64
C:\Work\Boost_1_63> bootstrap.bat
C:\Work\Boost_1_63> bjam -j4 architecture=x86 address-model=64 link=static stage
C:\Work\Boost_1_63> bjam --prefix=C:\opt\boost architecture=x86 address-model=64 link=static install

You can verify that the resulting .lib is x64 with dumpbin:

您可以使用 dumpbin 验证生成的 .lib 是否为 x64:

C:\Work> dumpbin /headers C:\work\boost_1_63\stage\lib\libboost_locale-vc140-mt-1_63.lib | findstr machine
8664 machine (x64)
8664 machine (x64)
8664 machine (x64)
8664 machine (x64) 
...

回答by RemiDav

With b2 the command is:

使用 b2 命令是:

b2 --build-dir=build/x64 address-model=64 threading=multi --build-type=complete --stagedir=./stage/x64

It will show default address-model: 32-bitat the beginning but will still build in 64-bit (how confusing).You should have the dlls created with names such as library-vc140-mt-x64-1_71.dllconfirming it is 64-bit.

它会default address-model: 32-bit在开头显示,但仍会以 64 位构建(多么令人困惑)。您应该使用名称创建 dll,例如library-vc140-mt-x64-1_71.dll确认它是 64 位。

source: Building Boost 32-bit and 64-bit libraries on Windows

来源:在 Windows 上构建 Boost 32 位和 64 位库

回答by sergtk

You may find following Boost.Build property:

您可能会发现以下Boost.Build 属性

address-model=64