【问题标题】:How to build 64-bit boost for visual studio on windows using the address-model flag?如何使用地址模型标志在 Windows 上为 Visual Studio 构建 64 位提升?
【发布时间】:2019-10-29 09:50:40
【问题描述】:

我正在尝试使用以下说明在 Visual Studio 的 x64 终端上构建 boost:https://www.boost.org/doc/libs/1_62_0/more/getting_started/windows.html#get-boost

我愿意:

boostrap

然后

.\b2 address-model=64

但它总是说:

C:\boost_1_70_0>.\b2 address-model=64
Performing configuration checks

    - default address-model    : 32-bit
    - default architecture     : x86

Building the Boost C++ Libraries.

...

然后继续构建所有内容的 32 位版本。我知道这一点,因为当我尝试将 boost 用于 CMake 之类的东西时,它抱怨它的 32 位:

C:\src\SimpleAmqpClient\simpleamqpclient-build>cmake -DBOOST_ROOT=C:\boost_1_70_0 -DBOOST_LIBRARYDIR=C:\boost_1_70_0\stage\lib ..
-- Found Boost 1.70.0 at C:/Program Files/boost/lib/cmake/Boost-1.70.0
--   Requested configuration: QUIET REQUIRED COMPONENTS chrono;system
-- Found boost_headers 1.70.0 at C:/Program Files/boost/lib/cmake/boost_headers-1.70.0
-- Found boost_chrono 1.70.0 at C:/Program Files/boost/lib/cmake/boost_chrono-1.70.0
-- No suitable boost_chrono variant has been identified!
--   libboost_chrono-mgw82-mt-d-x32-1_70.a (32 bit, need 64)
--   libboost_chrono-mgw82-mt-x32-1_70.a (32 bit, need 64)
CMake Error at C:/Program Files/boost/lib/cmake/Boost-1.70.0/BoostConfig.cmake:95 (find_package):
  Found package configuration file:

    C:/Program Files/boost/lib/cmake/boost_chrono-1.70.0/boost_chrono-config.cmake

  but it set boost_chrono_FOUND to FALSE so package "boost_chrono" is
  considered to be NOT FOUND.  Reason given by package:

  No suitable build variant has been found.

Call Stack (most recent call first):
  C:/Program Files/boost/lib/cmake/Boost-1.70.0/BoostConfig.cmake:124 (boost_find_dependency)
  C:/Program Files/CMake/share/cmake-3.15/Modules/FindBoost.cmake:273 (find_package)
  CMakeLists.txt:35 (FIND_PACKAGE)


-- Configuring incomplete, errors occurred!
See also "C:/src/SimpleAmqpClient/simpleamqpclient-build/CMakeFiles/CMakeOutput.log".

是的,我如何构建 64 位?

【问题讨论】:

  • 您确定它使用的是 64 位终端吗?您可能还必须通过运行vcvars64.bat 之类的东西来启用 64 位构建环境。 See here.
  • 您也可以尝试从常规的cmd 命令行构建:.\b2 toolset=msvc-15.0 address-model=64 --stagedir=stage link=shared 您可以在此处指定toolset,以及是否使用staticshared 构建库link 选项。 Full reference
  • @squareskittles vcvars64.bat 文件在哪里?我无法运行它。此外, .\b2 toolset=msvc-15.0 address-model=64 --stagedir=stage link=shared 似乎也适用于 32 位 - 与我原来的问题中的输出相同
  • 您使用的是什么版本的 Visual Studio?
  • Visual Studio 2019

标签: c++ visual-studio boost cmake b2


【解决方案1】:

查看我在这里给出的答案:How to build Boost 1.64 in 64 bits?
如果要显式指定工具集,则 Visual Studio 2019toolset=msvc-14.2

注意:确保从 Visual Studio tools Command Prompt 构建它
并忽略控制台上的- default address-model : 32-bit 输出,它会构建 64 位二进制文​​件。

【讨论】:

  • hmm 在使用它构建之后,我仍然收到相同的 cmake 抱怨,即找到 32 位 boost 库而不是 64 位
  • CmakeC:/Program Files/boost/ 上找到boost 而不是在C:\boost_1_70_0 上。您的机器上有多个 boost 库,但它正在查找错误的库。
  • 感谢有关 boost false 默认地址模型消息的说明。
  • 这是真的,输出是假的,确认。
【解决方案2】:

我刚刚遇到了这个问题。尽管我在命令行中指定了address-model=64,并且我的PATH 中没有32 位工具,而64 位工具在,但Jam 使用了32 位工具。它甚至不知道自己正在这样做:它把x64 放在它使用32 位工具创建的32 位库的名称中,它已经竭尽全力寻找和调用这些工具。我喜欢“智能”构建系统。

我不知道为什么会这样,但我通过编辑 bin.v2\standalone\msvc\msvc-{version}\address-model-64\architecture-x86\msvc-setup.bat 并在 SET PATH=... 行中将 ...\bin\Hostx64\x64 移动到 ...\bin\HostX86\x86 之前解决了这个问题。

正如另一个答案中提到的,即使它正确构建 64 位二进制文​​件,它仍会报告“默认地址模型:32 位”。

【讨论】:

    【解决方案3】:

    My guide 有详细的说明,这些说明可能对如何在支持 python 和 mpi 的 Visual Studio 2019 中的 Windows 10 上构建 64 位加速有用。我写了笔记以防我需要再做一次。

    我认为这可能与省略--有关

    b2 --address-model=64
    

    但有人告诉我这是不正确的。

    【讨论】:

    • 对我来说,它不是“--address-model”而是“address-model”。像这样的答案花费了很多人很多时间
    • @IceFire 抱歉,我把你赶走了,不确定何时需要 -- 或打破。我不再构建 boost,而是简单地获取预编译的二进制文件。
    猜你喜欢
    • 2012-08-23
    • 1970-01-01
    • 2013-10-31
    • 2015-12-19
    • 1970-01-01
    • 2011-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多