【问题标题】:pybind11 "Python is 64-bit, chosen compiler is 32-bit"pybind11 "Python 是 64 位的,选择的编译器是 32 位的"
【发布时间】:2017-07-30 08:44:35
【问题描述】:

我正在尝试在安装了 VisualStudio 2015 的 Windows 机器上编译 pybind11。我还安装了 python 3.5.3 64bit 和 cmake 2.8.12。我得到错误:

CMake Error at tools/FindPythonLibsNew.cmake:122 (message):
  Python config failure: Python is 64-bit, chosen compiler is 32-bit
Call Stack (most recent call first):
  tools/pybind11Tools.cmake:16 (find_package)
  CMakeLists.txt:28 (include)

我没有“选择”编译器为 32 位,并且查看 CMakeLists.txt,我没有找到任何地方指定要运行哪个编译器。 那么如何告诉 pybind11/cmake 编译为 64 位?

【问题讨论】:

  • 您必须从 VS2015(如果您从那里编译)或从命令行提示符选择您的编译器版本。此外,强烈建议升级您的 cmake 版本。
  • @utopia,我正在从命令行构建,如何“选择”编译器为 64 而不是 32?我需要在 CMakeLists.txt 文件中添加一些内容吗?

标签: visual-studio-2015 cmake pybind11


【解决方案1】:

您应该像这样指定 64 位 VS 编译器:

cmake "/path/to/src/" -G"Visual Studio 14 2015 Win64"

否则默认选择32位。

【讨论】:

  • 好的,虽然它需要一些锻炼:comman 应该是 cmake .. .. -G"Visual Studio 14 2015 Win64" 并且 cmake 应该升级到 3.x,因为 2.8.12 没有了解 VS 2015。(pybind11 文档声明需要 2.8.12)
  • 就我而言,Windows 10 Visual Studio Community cmake CMakeLists.txt -G"Visual Studio 16 2019" -A x64
  • 简单地做cmake .. -G"Visual Studio 14 2015 Win64"对我有用。非常感谢
【解决方案2】:

如果您使用 Ninja 生成器并且遇到此错误,请确保在 64 位模式下运行 VS Dev 命令提示符:

VsDevCmd.bat arch=amd64 && cmake <options> ... 

【讨论】:

    【解决方案3】:

    你可以这样做:

    cmake .. -G"Visual Studio 14 2015 Win64"
    cmake --build . --config Release --target check
    

    或基于编译 Windows 测试用例部分here 中的引用:

    如果所有测试都失败,请确保 Python 二进制文件和测试用例 编译为相同的处理器类型和位数(即 i386 或 x86_64)。您可以将 x86_64 指定为 使用 cmake -A x64 生成 Visual Studio 项目 ..

    你可以这样做:

    cmake -A x64 ..
    cmake --build . --config Release --target check
    

    【讨论】:

      猜你喜欢
      • 2014-07-28
      • 2018-06-14
      • 2015-06-06
      • 2011-04-12
      • 1970-01-01
      • 2018-08-04
      • 2013-07-03
      • 1970-01-01
      相关资源
      最近更新 更多