Nominate our 2022 Qt Champions!

FLAC file as resource causes compilation to fail

  • Hello,

    I added a 40 MB FLAC file as a resource in QTCreator to a new QtQuick project. Unfortunately that causes complation to fail with the following message:

    virtual memory exhausted: Cannot allocate memory
    Makefile:630: recipe for target 'qrc_qml.o' failed

    When trying to compile a new project with a FLAC file, the cc1plus process will start eating up memory immediately - it fails even with 8 GB physical memory + 8 GB swapfile.
    When I compile another project with many PNG images (~20 MB), this does not cause any problems, and it barely registers in memory.

    Is this a bug or are there limitations in file types or sizes when it comes to the QT resource files?

    (System specs: Qt 5.6.0 ; Qt Creator 3.6.1; GCC 4.9.1 20140922 64 bits; Debian GNU/Linux 64 bits; downloaded from QT website (not repo); compiling for Android ARM7 and x86 desktop - same problem )

    (Edit: the version from the Debian repositories has the same problem. It uses the system's GCC instead, which is GCC 5.3.1 )

  • Lifetime Qt Champion

    Just tried on windows with 2x files from here
    so ca 60 MB and it takes a moment but works fine.

    There should be no limit of type but all files are converted into array to compile into
    the code so it can get too big for compiler.

    Could it be the flag file itself somehow ?

  • Thank you for the reply!
    I tried it also with a 30 MB *.deb (a kernel package) and I had the same problem. I will try from Windows and see if it is a Linux-only problem.

    Additionally could you check the memory usage while compiling?


  • Lifetime Qt Champion

    Did check mem usage. its almost stay at same.
    very little change. not anything like u see.

    Perhaps for good measure u can run my sample in linux?
    (50 MB)

  • Moderators

    You shouldn't compile a resource this big into the binary to begin with! Load it at runtime instead. For example look at this thread.