Use 64 bit compiler in Visual Studio

孤街浪徒 提交于 2019-12-03 11:32:21

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!