Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use the 64-bit Visual C++ Toolset in Visual Studio 2017

My (quite large) C++ project has grown to a point where I get a C1060: compiler is out of heap space error when trying to compile my project.

I'm compiling on a 64-bit Windows 10 machine, but it seems that Visual Studio is compiling my project with the 32-bit toolset (see screenshot below).

32 bit compiler driver

The C1060 help page asks me to use the 64-bit toolset, but the link provided talks about how to enable it when compiling with the command line only.

Is there any way to set project properties or something else in Visual Studio 2017 to tell it to use the 64-bit compiler toolset (which is already installed on my machine)?

like image 818
Bernard Avatar asked Sep 05 '17 13:09

Bernard


People also ask

How do I run Visual Studio in 64-bit mode?

From the Visual Studio menu, choose Test, then choose Processor Architecture for AnyCPU projects. Choose x64 to run the tests as a 64-bit process.

How do I change my Visual Studio from 32 bit to 64-bit?

From the BUILD menu in Visual Studio, select Configuration Manager. From the Active solution platform drop-down list, select New. The New Solution Platform dialog displays. In the Type or select new platform combination box, select x64.

What version of C++ does Visual Studio 2017 use?

Visual Studio 2017 version 15.3/std:c++17 enables the set of C++17 features implemented by the compiler.


1 Answers

This is how I made Visual Studio 2017 use the x64 toolset, as per this answer:

Open the .vcxproj file with your favourite text editor, find this line:

<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />

Then add this immediately after it:

<PropertyGroup>
  <PreferredToolArchitecture>x64</PreferredToolArchitecture>
</PropertyGroup>

That answer was for Visual Studio 2013 but it works for 2017 too.

Additional Note: However, it turns out this didn't actually solve my problem. The 64-bit toolset ate up all the memory on my machine and forced me to need to reboot. When I rolled back the latest changes to the code, it compiles using ~2.8GB for the 32-bit compiler, and compiles using ~4.2GB for the 64-bit compiler (the latest code consumed ~6.4GB before freezing my task manager on my 8GB machine). I'll be looking through the new code and attempting to figure out why so much more memory was needed.

like image 64
Bernard Avatar answered Nov 10 '22 23:11

Bernard