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
How do you build the x64 Boost libraries on Windows?
提问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
回答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-bit
at 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.dll
confirming 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