Visual studio 2015 pybind11“;Python是64位的,选择的编译器是32位的;

Visual studio 2015 pybind11“;Python是64位的,选择的编译器是32位的;,visual-studio-2015,cmake,pybind11,Visual Studio 2015,Cmake,Pybind11,我正在尝试在安装了VisualStudio2015的Windows计算机上编译pybind11。我还安装了python 3.5.3 64位和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

我正在尝试在安装了VisualStudio2015的Windows计算机上编译pybind11。我还安装了python 3.5.3 64位和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位

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

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

否则,默认情况下它会选择32位。

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

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

否则,默认情况下会选择32位。

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

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

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

VsDevCmd.bat arch=amd64 && cmake <options> ... 
VsDevCmd.bat arch=amd64&&cmake。。。
您可以执行以下任一操作:

cmake .. -G"Visual Studio 14 2015 Win64"
cmake --build . --config Release --target check
或者根据编译windows测试用例一节中的这句话:

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

你可以做:

cmake -A x64 ..
cmake --build . --config Release --target check
您可以执行以下任一操作:

cmake .. -G"Visual Studio 14 2015 Win64"
cmake --build . --config Release --target check
或者根据编译windows测试用例一节中的这句话:

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

你可以做:

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

您必须从VS2015(如果从那里编译)或命令行提示符中选择编译器版本。另外,强烈建议升级您的cmake版本。@utopia,我正在从命令行构建,如何“选择”编译器为64而不是32?是否需要向CMakeLists.txt文件中添加一些内容?您必须从VS2015(如果您是从那里编译)或命令行提示符中选择编译器版本。另外,强烈建议升级您的cmake版本。@utopia,我正在从命令行构建,如何“选择”编译器为64而不是32?我需要在CMakeLists.txt文件中添加一些内容吗?好的,尽管它需要一些训练:comman应该是cmake-G“Visual Studio 14 2015 Win64”和cmake应该升级到3.x,因为2.8.12不知道VS 2015。(pybind11文档声明需要2.8.12)在我的例子中,Windows 10 Visual Studio社区
cmake CMakeLists.txt-G“Visual Studio 16 2019”-一个x64
简单地执行
cmake-G“Visual Studio 14 2015 Win64”
为我做了这件事。感谢一个虽然需要一些锻炼但仍然有效的lotOK:comman应该是cmake-G“Visual Studio 14 2015 Win64”和cmake应该升级到3.x,因为2.8.12不知道VS 2015。(pybind11文档声明需要2.8.12)在我的例子中,Windows 10 Visual Studio社区
cmake CMakeLists.txt-G“Visual Studio 16 2019”-一个x64
简单地执行
cmake-G“Visual Studio 14 2015 Win64”
为我做了这件事。谢谢