PDA

View Full Version : Qt resources - cc1plus.exe:-1: error: out of memory allocating



atomic
24th July 2015, 19:38
Hi,

I try compile code where inside resources I have files which have +- 20MB and i get following error


cc1plus.exe:-1: error: out of memory allocating 1073745919 bytes

It is a normal? Whether Qt Resources have some restrictions about size? Or it is a problem with my compiler? I use Qt 5.4 with ming 4.9.1

Thanks,

d_stranz
25th July 2015, 00:32
The Qt resource compiler, rcc, converts the binary data in the .qrc resource file into unsigned char arrays in the qrc_[yourprojectname].cpp file, which is then compiled into an object file by the C++ compiler. This second step is what is blowing up on you. Your 20MB files are resulting in arrays that are too big for the compiler to build.

There is a StackOverflow (http://stackoverflow.com/questions/18352117/qt-resource-system-and-msvc-c1060)post that covers this (for MSVC compiler, but the issue and solution are the same). In short, you can't include resources of this size in the qrc file. You have to deliver them as external resources that are loaded at run time.

atomic
25th July 2015, 16:05
Thanks that works fine but only for small / medium files.

For example my qrc file looks like this


<RCC>
<qresource prefix="/">
<file>ebook.pdf</file>
<file>ebook2.pdf</file>
<file>ebook3.pdf</file>
<file>ebook4.pdf</file>
<file>ebook5.pdf</file>
<file>ebook6.pdf</file>
<file>ebook7.pdf</file>
<file>ebook8.pdf</file>
<file>ebook9.pdf</file>
<file>ebook10.pdf</file>
</qresource>
</RCC>

10 ebooks, +- 500MB

and when i run rcc compiler by means of command


rcc --binary --compress 9 resources.qrc -o ebooks.rcc

then I see dialog of windows application crash


rcc.exe has stopped working...

I have a lot of memory so that is not a problem. I think that rcc compiler has some restrictions for files size but I do not know why... why? Why they can't handle file which have +-500MB ( or of course more ) Is there any way for solve this problem?

For this file I think I can divide it on 10 parts and then create 10 rcc files... but what when I have one big file? One file which have 500MB? First divide this file on several small parts and then add to qt resource system? And on end user machine connect all parts to original file?

Thanks,

anda_skoa
25th July 2015, 18:19
Why would you want your executable to have several hundred megabytes, maybe even gigabytes in size?

Startup time would be horrible.

Cheers,
_

atomic
25th July 2015, 18:40
It is not my idea but that is one of requirements of project - one executable file which contains all dependencies.


Startup time would be horrible.
I have seen several files especially installers or archive of libraries which have similar ( often greater ) sizes and they startup time was a normal / fast.

Thanks,

ChrisW67
26th July 2015, 02:52
I assume your compiler and rcc are 32-bit applications. On Windows this gives them a total memory allocation limit of 3GiB. Your compiler is choking trying to allocate a single chunk of memory circa 1GiB in order to slurp up the source file generated by rcc. I am not too surprised this failed either because there was not a GB to be had in total, or because there was not a GB of contiguous memory to be had.

IIRC rcc converts each resource byte into a string "0xnn," to be part of a C++ source file. That is, there is a four/five fold increase in size over the original binary file size. Your 500MB turns into 2GB of source code. The compress option is of little use with PDFs because they are already compressed. This source is built into the executable/data sections of your executable.

Installers and the like have a very small executable/data section and use other methods to embed data into the same executable file. They get at that data at run time by reading from the file, not by looking for an in-memory structure. I do not know if the Windows native resource system works this way. You might like this:
http://stackoverflow.com/questions/2627004/embedding-binary-blobs-using-gcc-mingw

BTW, I would still baulk at a 500MB executable.