Search code examples
qtqmake

In Qt, when should you use RESOURCES vs. DISTFILES vs. OTHER_FILES


Within the .pro file, things are straightforward if you're including header files (use HEADERS), C++ files (use SOURCES) and Objective-C / Objective-C++ files (use OBJECTIVE_SOURCES), but it is less clear to me how other file types should be included.

e.g. looking at various examples that Qt provide, there is inconsistency about whether QML files should be DISTFILES, OTHER_FILES or contained within a .qrc file (i.e. RESOURCES). I've gone with putting QML files in a qml.qrc file.

My question has arisen because I'm including data files, such as audio .wav files, within a .qrc file (also as shown in Qt examples; e.g. Qt Quick Demo - Maroon in Trouble) but this has slowed compiling down to a crawl. And in the case of MinGW on Windows, it simply crashes with an out of memory error when it reaches 1GB. There must be a better way to include these!

Could you provide a guide as to when to use:

  • DISTFILES
  • OTHER_FILES
  • RESOURCES

Solution

  • Quoting from the qmake manual:

    RESOURCES

    Specifies the name of the resource collection files (qrc) for the target. [...]

    DISTFILES

    Specifies a list of files to be included in the dist target. This feature is supported by UnixMake specs only. [...]

    OTHER_FILES

    This seems in fact undocumented, at least I could not find anything. As far as I can tell all files listed here are only linked in project explorer (of Qt Creator for example) and are not treated in any way by qmake.


    As for your example you might consider shipping the files as they are and not include them in any resource file, because they are compiled into the binary.

    You may also take a look at compiling external resources and using them for your large files to keep the simplicity of Qt's resource system.