即使启用了Visual Studio 14 2015 Win64工具链,也会使用32位工具链进行编译

时间:2017-09-18 11:30:23

标签: c++ visual-studio-2015 tensorflow cmake msbuild

我正在尝试在Windows上编译TensorFlow CMake构建,这需要64位工具链在编译期间不会耗尽内存。但是,即使在命令提示符中启用了Visual Studio 14 2015 Win64工具链,32位工具链也可用于编译,如显示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.0\VC\vcvarsall amd64",但无济于事。 32位工具链最后仍用于编译。

我错过了什么?

2 个答案:

答案 0 :(得分:4)

执行CMake时,必须在64位版本中指定它是否需要它:

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

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

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

并以32位模式配置它。

答案 1 :(得分:2)

来自CMake --help命令行:

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

如果要构建x64目标,则需要指定正确的CMake生成器:

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