1

I'm trying to compile the library OpenGV and I get the error MSVC C1060 "compiler out of heap space".

I tried to go change to x64 architecture by adding

<PreferredToolArchitecture>x64</PreferredToolArchitecture>
<PlatformTarget>x64</PlatformTarget>

to the .vxcproj file, without success. I notice however that in the resource manager, MSBuild 32 bit is still being used. Could this be the problem, and if so, how can I change the build tool (i.e. the MSbuild version), through, say, GitBash?

Lilla
  • 209
  • 3
  • 9

1 Answers1

3

If you're compiling the project through the Visual Studio IDE, the Visual Studio IDE silently uses a 32-bit compiler. To change this behavior, use the command:

msbuild {solution-name}.sln /property:Configuration=Release"

To find the path to the msbuild command on your system, use the command below:

where msbuild
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe

If the where msbuild command does not return a path like C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe, but your system has msbuild installed, go to the system variables and add the MSBuild.exe path to the system path in the file structure where Microsoft Visual Studio is installed. Remove other msbuild path variable from system variables (like C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe). Otherwise, this change may not work.

In another graphics library (solution, issue) it is reported how to solve a similar problem and its solution is reported as solved as above.

When installing OpenGV under Window it is stated in the documentation that the msbuild configuration should be changed as follows:

msbuild opengv.sln /p:Configuration=Release

In addition, if the cmake build tool will be used in the project, the following declaration should be made using the -G option to compile for x64 target machine:

  cmake -G "Visual Studio 16 2019" -A x64   ../
# cmake -G "Visual Studio 16 2019" -A Win32 ../
# cmake -G "Visual Studio 16 2019" -A ARM   ../
# cmake -G "Visual Studio 16 2019" -A ARM64 ../
Sercan
  • 4,739
  • 3
  • 17
  • 36
  • So changing Configuration to Release will automatically switch to 64-bit compiler? – kiner_shah Dec 19 '21 at 10:11
  • 1
    How to solve a similar problem in another graphics library has been reported and the solution has been shared: [g2opy](https://github.com/uoip/g2opy/issues/29), [issue](https://github.com/uoip/g2opy/issues/25). – Sercan Dec 19 '21 at 10:14
  • 1
    [The OpenGV Documentation](https://laurentkneip.github.io/opengv/page_installation.html) already explains how CMAKE should be configured: `msbuild opengv.sln /p:Configuration=Release`. – Sercan Dec 19 '21 at 10:18
  • 1
    Yes, it does indeed. Can you include these points in your answer by editing them? – kiner_shah Dec 19 '21 at 10:19
  • 1
    I edited the post. Hope it will be useful for the community. – Sercan Dec 19 '21 at 10:33
  • @SercanSebetçi Did you mean c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\15.0\Bin\amd64\MSBuild.exe ? (the amd64 part) – Lilla Dec 19 '21 at 10:33
  • 1
    I tried it at my local. My way is the way I share. – Sercan Dec 19 '21 at 10:34
  • 1
    [What's New in MSBuild 16.0 - Changed Path](https://learn.microsoft.com/en-us/visualstudio/msbuild/whats-new-msbuild-16-0?view=vs-2022#:~:text=For%20example%2C%20the%20path%20to,module%20to%20locate%20MSBuild%3A%20vssetup.) – Sercan Dec 19 '21 at 10:36
  • After trying to build again, before implementing your suggestions, I noticed that C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe is already being used (and it is 32 bit). I had already specified "-A x64" in the CMake build tool. – Lilla Dec 19 '21 at 13:11
  • The fact that the directory where MsBuild.exe is located is in the x86 file structure does not mean that it is running in 32-bit mode. – Sercan Dec 19 '21 at 13:24
  • The following command is used to force MSBuild to run in 32-bit mod mode: `msbuild {solution-name}.sln /t:build /p:Configuration=Release;Platform=x86` I recommend you to read [this post](https://stackoverflow.com/questions/1074654/how-do-i-force-msbuild-to-compile-for-32-bit-mode) as well. – Sercan Dec 19 '21 at 13:30
  • @SercanSebetçi However, the process that is running is named "MSBuild.exe (32 bit)". To the post you linked: I have already tried to follow their tips but MSBuild is no matter what I do still executed in the 32 bit version. What is best in this case is to try to run a 64 bit version of it, right? – Lilla Dec 19 '21 at 13:40
  • The reason for this error is (most likely) stated to be the 32-bit compiler run of msbuild in the background, even if you set the target architecture to 64-bit to improve debugging performance. I shared one of the ways to change this behavior in the post. – Sercan Dec 19 '21 at 13:44
  • 1
    @SercanSebetçi Thanks again, I'll try a build overnight an report the results. – Lilla Dec 19 '21 at 14:12
  • @SercanSebetçi I tried implementing your suggestion (all the time building from command line, no IDE open), MSBuild 32 bit was still being used. I even changed to ...MSBuild\15.0\Bin\amd64\MSBuild.exe, and still it didn't work – Lilla Dec 20 '21 at 07:41
  • (though, when using the amd64 folder, MSBuild wasn't showing the text "32 Bit" anymore) – Lilla Dec 20 '21 at 10:28
  • Have you tried the `msbuild` tool with root directory **"Microsoft Visual Studio\2019\Community"**? – Sercan Dec 20 '21 at 17:05
  • If it calls msbuild without specifying a path from the command line, you may be running a different msbuild file. You can see [this link](https://pureinfotech.com/list-environment-variables-windows-10/) to view windows environmental variables, and [this link](https://www.computerhope.com/issues/ch000549.htm) to change environmental variables. – Sercan Dec 20 '21 at 17:09