pybind11 "Python 是 64 位的,选择的编译器是 32 位的"



我正在尝试在安装了VisualStudio 2015的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 位。

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

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

你可以做:

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

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

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

你可以做:

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

最新更新