【问题标题】:How do you build the x64 Boost libraries on Windows?如何在 Windows 上构建 x64 Boost 库?
【发布时间】:2010-09-23 01:34:29
【问题描述】:

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

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

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

【问题讨论】:

    标签: c++ visual-studio-2005 boost 64-bit boost-build


    【解决方案1】:

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

    看例如here.

    【讨论】:

    • 此答案也适用于较新的 boost 构建工具 b2
    • 那你能解释一下吗? C:\Boost\boost_1_61_0>.\b2 --stagedir=lib\x64 architecture=x86 address-model=64 link=static --build-type=complete stage 执行配置检查 - 32 位:是
    • address-model 似乎没有显示在b2 --help (b2 4.3) 的输出中,如何从命令行获得帮助?
    【解决方案2】:

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

    以下是我在 Visual Studio 15 2017 社区版上构建 Boost 1.63 所必须做的。

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

    C:\Work\Boost_1_63> C:\Program Files (x86)\Microsoft Visual Studio\2017\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
    

    您可以使用 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) 
    ...
    

    【讨论】:

      【解决方案3】:

      使用 b2 命令是:

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

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

      来源:Building Boost 32-bit and 64-bit libraries on Windows

      【讨论】:

        【解决方案4】:

        您可能会发现以下Boost.Build property

        address-model=64
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2013-06-13
          • 1970-01-01
          • 2021-09-19
          • 2011-12-18
          • 2015-08-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多