Use 64 bit compiler in Visual Studio

后端 未结 1 983
没有蜡笔的小新
没有蜡笔的小新 2020-12-29 07:44

I use Visual Studio 2017. In a project (that I target as x64), I get error : C1060, compiler is out of heap space, and sadly learned there happen to exist a memory limitatio

相关标签:
1条回答
  • 2020-12-29 08:32

    By default Visual Studio uses the 32-bit toolchain (i.e. the compiler is 32-bit and cross-compiles 64-bit executables). Visual Studio 2015 and 2017 include both 32-bit and 64-bit versions of all the compilers (x86, x64, arm, arm64).

    You can opt-in to using the 64-bit toolchain on a 64-bit system by two methods:

    1. Add a environment variable on your build machine (either system-wide or from a VS Developer Command Prompt).

    For example:

    set PreferredToolArchitecture=x64
    devenv
    
    1. You can edit your vcxproj files to do this as well with the <PreferredToolArchitecture>x64</PreferredToolArchitecture> element:

    For example:

    <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
      <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
        <ConfigurationType>Application</ConfigurationType>
        <UseDebugLibraries>true</UseDebugLibraries>
        <PlatformToolset>v141</PlatformToolset>
        <PreferredToolArchitecture>x64</PreferredToolArchitecture>
        <CharacterSet>Unicode</CharacterSet>
      </PropertyGroup>
    

    I use the second method in the UWP (C++/WinRT) versions of my Direct3D Game VS Templates, and I just noticed that I should add it to my UWP (C++/CX) and Win32 versions. The Xbox One XDK automatically does this in it's platform build rules as well.

    Note this question has been answered in the past: How to make Visual Studio use the native amd64 toolchain

    0 讨论(0)
提交回复
热议问题