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 limitation for compilation.
When monitoring CL.exe, it indeed stop just before reaching 4GB. So it looks like CL.exe is by default a 32bits application, as seen at : https://docs.microsoft.com/en-us/cpp/build/how-to-enable-a-64-bit-visual-cpp-toolset-on-the-command-line
After reading this page, I installed "Universal Windows Platform workload" hoping to get access to a 64 bit version of CL.exe. But no change when compiling my project, and I can't see a single option in visual studio to choose compiler version.
I assume that there must exist a workaround to be able to use more than 4GB for a single compilation unit, but I couldn't find it for now. Any help would be much appreciated.
Edit : I hit limitation in Debug mode. Compilation is doing fine in Release mode. Which is suppose makes sense.
Visual Studio 2022 on Windows is now a 64-bit application.
Build and run your code in Visual Studio To build your project, choose Build Solution from the Build menu. The Output window shows the results of the build process. To run the code, on the menu bar, choose Debug, Start without debugging. A console window opens and then runs your app.
To enable x64 as a CPU platform targetClick Configuration Manager. In the Configuration Manager dialog, open the Active solution platform drop-down list box and click <New> …. In the New Solution Platform dialog, select x64 in the Type or select the new platform drop-down list box.
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:
For example:
set PreferredToolArchitecture=x64
devenv
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With