即使Visual Studio 14 2015 Win64工具链已启用,也将32位工具链用于编译

32 bit toolchain is used for compilation even though Visual Studio 14 2015 Win64 toolchain is enabled

本文关键字:工具 也将 32位 用于 编译 启用 2015 Win64 Visual 即使 Studio      更新时间:2023-10-16

我试图在窗口上编译TensorFlow Cmake构建,这需要64位工具链在编译过程中不会用完存储器。但是,即使Visual Studio 14 2015 WIN64工具链在命令提示符中启用,但32位工具链也被用于汇编,这是由Task Manager明显的,该任务管理器显示了MSBuild (32 bit)Microsoft(R) C/C++ Compiler Driver (32 bit)流程。因此,error: c1060: compiler is out of heap space被抛出了一点点。

这是我到目前为止所做的:启用64位工具链,我打开VS2015 x64 Native Tools Command Prompt。配置CMAKE时,我获得输出

-- Building for: Visual Studio 14 2015
-- The C compiler identification is MSVC 19.0.24215.1
-- The CXX compiler identification is MSVC 19.0.24215.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonLibs: C:/Users/kasper/Anaconda3/libs/python35.lib (found version "3.5.2")
-- Configuring done
-- Generating done

因此,Cmake似乎已经选择了64位编译器。futher,在命令提示中运行cl给出

Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

我还尝试在配置Cmake之前运行"C:Program Files (x86)Microsoft Visual Studio 14.0VCvcvarsall amd64",但无济于事。32位工具链最终仍用于编译。

我缺少什么?

执行cmake时,必须在64位版本中指定要它:

cmake -G "Visual Studio 14 2015 Win64" [...]

否则,在您的情况下,默认情况下它与

相同
cmake -G "Visual Studio 14 2015" [...]

并以32位模式配置。

来自cmake -help命令行:

Visual Studio 14 2015 [arch] = Generates Visual Studio 2015 project
files.  
Optional [arch] can be "Win64" or "ARM".

如果要为X64目标构建,则需要指定正确的CMake Generator:

CMake -G "Visual Studio 14 2015 Win64" ....