【问题标题】:Compiler out of heap space and MSBuild 32 bit编译器堆空间不足和 MSBuild 32 位
【发布时间】:2022-01-21 09:24:56
【问题描述】:

我正在尝试编译库 OpenGV,但我收到错误 MSVC C1060 "compiler out of heap space"。

我尝试通过添加更改为 x64 架构

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

到 .vxcproj 文件,但没有成功。然而,我注意到在资源管理器中,仍在使用 MSBuild 32 位。这可能是问题吗?如果是这样,我该如何通过 GitBash 更改构建工具(即 MSbuild 版本)?

【问题讨论】:

  • 将这些行添加到 .vcxproj 文件后,您是否重新启动了 Visual Studio?
  • 为什么要手动编辑项目文件?
  • 你检查过MS页面上的9个技巧吗? docs.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/…
  • @kiner_shah 我从命令行做所有事情,这样 VS 就不会在后台使用太多内存
  • @PaulSanders 我正在遵循有关如何更改为 x64 的建议

标签: c++ visual-studio compiler-errors


【解决方案1】:

如果您通过 Visual Studio IDE 编译项目,Visual Studio IDE 会静默使用 32 位编译器。要更改此行为,请使用以下命令:

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

要在您的系统上找到msbuild 命令的路径,请使用以下命令:

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

如果where msbuild 命令没有返回类似C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe 的路径,但您的系统安装了msbuild,请转到系统变量并将MSBuild.exe 路径添加到系统路径 在安装 Microsoft Visual Studio 的文件结构中。从系统变量中删除其他msbuild 路径变量(如C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe)。否则,此更改可能不起作用。

在另一个图形库(solutionissue)中报告了如何解决类似问题,其解决方案报告为已解决。

在Window下安装OpenGV时,文档中说明msbuild配置应更改如下:

msbuild opengv.sln /p:Configuration=Release

另外,如果项目中将使用cmake 构建工具,则应使用-G 选项进行以下声明以针对x64 目标机器进行编译:

  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 ../

【讨论】:

  • 如何解决另一个图形库中的类似问题,已分享解决方法:g2opy,issue
  • The OpenGV Documentation 已经解释了如何配置 CMAKE:msbuild opengv.sln /p:Configuration=Release
  • 是的,确实如此。您可以通过编辑将这些要点包含在您的答案中吗?
  • 我编辑了这篇文章。希望它对社区有用。
  • 我在本地试过。我的方式就是我分享的方式。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-07-17
  • 1970-01-01
  • 2012-06-15
  • 1970-01-01
  • 2010-11-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多