You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Qt资源编译器rcc的-t选项如何使用?解决C1060堆空间不足

Fixing "C1060: compiler is out of heap space" with Qt RCC's -t (--threshold) Option

I’ve dealt with this exact heap space error when using RCC alongside MSVC, so let me break down how to use the -t (or --threshold) option to resolve it.

Why the error happens

The C1060 error pops up because RCC embeds large resources directly into the generated .cpp file by default. When MSVC tries to compile that massive file full of raw data blobs, it runs out of heap space. Since you can’t use a .pro file to mark resources as external (the standard workaround), the -t option is your best bet here.

What -t/--threshold does

This option sets a size limit (measured in kilobytes). Any resource larger than this threshold will be saved as an external binary .rcc file instead of being baked into the C++ code. This cuts down the size of the .cpp file drastically, which fixes the heap overflow issue for the compiler.

Adjusting your current RCC command

Looking at your existing command:

C:\Qt\Qt5.6.3\5.6.3\msvc2015\bin\rcc.exe -threshold 70 -compress -1 -name "%(Filename)" -o ".\_qt\win\qrc_%(Filename).cpp" "%(FullPath)"

You already have -threshold 70 set, which means resources over 70KB are externalized. If you’re still hitting the error, you need to lower this value to force more large resources out of the generated .cpp. For example, try setting it to 20KB:

C:\Qt\Qt5.6.3\5.6.3\msvc2015\bin\rcc.exe -threshold 20 -compress -1 -name "%(Filename)" -o ".\_qt\win\qrc_%(Filename).cpp" "%(FullPath)"

Key notes to remember

  • Runtime loading: External .rcc files need to be registered at runtime using QResource::registerResource(). Make sure you call this early in your application’s startup (e.g., right before you use the resources).
  • Distribution: You’ll need to include the generated .rcc files with your application package. Place them in the same directory as your executable, or use a known path that your app can access.
  • Tune the threshold: If you still run into issues, keep lowering the threshold. For example, setting -threshold 1 would externalize almost all non-trivial resources, which is a safe (if extreme) fix.

内容的提问来源于stack exchange,提问作者Tom

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:24:35