如何使用address-model标志在Windows上为Visual Studio构建64位boost?

4
我正在尝试使用以下说明在Visual Studio的x64终端上构建boost:https://www.boost.org/doc/libs/1_62_0/more/getting_started/windows.html#get-boost 我执行以下步骤:
bootstrap 然后
.\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位版本。我知道这点,因为当我尝试在像CMake这样的地方使用boost时,它会抱怨它是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位构建环境。请见此处 - Kevin
你也可以尝试从常规的 cmd 命令行构建:.\b2 toolset=msvc-15.0 address-model=64 --stagedir=stage link=shared。你可以在那里指定 toolset,以及使用 link 选项构建 staticshared 库。完整参考 - Kevin
@squareskittles,vcvars64.bat文件在哪里?我运行它时遇到了麻烦。此外,.\b2 toolset=msvc-15.0 address-model=64 --stagedir=stage link=shared似乎也会构建32位 - 与我的原始问题输出相同。 - BigBoy1337
你正在使用哪个版本的Visual Studio? - Kevin
Visual Studio 2019 - BigBoy1337
有人应该从Boost来看看这个!这太尴尬了。 - user997112
3个回答

7

请查看我在这里给出的答案:如何在 64 位系统上构建 Boost 1.64?
如果要明确指定工具集,则使用 Visual Studio 2019,其中 toolset=msvc-14.2

注意:请确保从“Visual Studio 工具命令提示符”中构建它
忽略控制台上的 - default address-model : 32-bit 输出,它会构建 64 位二进制文件。


构建后,我仍然遇到了相同的 CMake 问题,它发现了 32 位的 Boost 库而不是 64 位的。 - BigBoy1337
Cmake 正在从 C:/Program Files/boost/ 寻找 boost,而不是在 C:\boost_1_70_0 中寻找。您的计算机上有多个 boost 库,因此它正在找到错误的库。 - kenba
1
感谢您提醒关于Boost的错误默认地址模型消息。 - sailfish009
这是真的,输出是假的,已确认。 - metablaster

0
我刚遇到了这个问题。尽管我在命令行上指定了address-model=64,并且32位工具不在我的PATH中,64位工具却在其中,Jam还是使用了32位工具。而且它甚至不知道自己在这样做:它使用找到并调用的32位工具创建32位库时,在这些库的名称中放置了x64。我喜欢“智能”构建系统。
我不知道为什么会出现这种情况,但我通过编辑bin.v2\standalone\msvc\msvc-{version}\address-model-64\architecture-x86\msvc-setup.bat来解决它,并将...\bin\Hostx64\x64移动到SET PATH=...行中...\bin\HostX86\x86之前。
正如另一个答案中所提到的,即使它正确地构建了64位二进制文件,它仍然报告“默认地址模型: 32位”。

-3

我的指南提供了详细的说明,可能对在Windows 10上使用Visual Studio 2019构建带有Python和MPI支持的64位boost库有所帮助。我写下这些笔记是为了以防将来需要再次进行此操作。

我认为这可能与遗漏--有关。

b2 --address-model=64

但有人告诉我那不正确。

2
对我来说,不是“--address-model”,而是“address-model”。这样的回答浪费了许多人的时间。 - IceFire
@IceFire 抱歉让你困惑了,我不确定何时需要使用 -- 或打破它。我不再构建 boost,而是直接获取预编译的二进制文件。 - JoseOrtiz3

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接