24

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

3 Answers 3

17

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.

5
  • Just edited DIST_FILES to DISTFILES - thanks for the correction Jun 29, 2016 at 14:59
  • @PaulMasri All your questions answered, or any other request? You're welcome.
    – maxik
    Jun 29, 2016 at 17:48
  • Can you explain what you mean by "you might consider shipping the files as they are"? Do you mean ship them alongside the executable or somehow include them in the executable but bypass the resource compiler? Jun 30, 2016 at 10:13
  • @PaulMasri That is up to you. I though about the files as they are. Make a folder besides the executable and load them in the application using ´QString QCoreApplication::applicationDirPath()´ and the trailing subfolder and file. The latter I would not recommend. Instead look at the last provided link (doc.qt.io/qt-5/resources.html#external-binary-resources).
    – maxik
    Jun 30, 2016 at 10:27
  • @PaulMasri-Stone Still anything open to you? If not consider accepting any provided answer.
    – maxik
    Oct 25, 2016 at 6:22
6
  • DISTFILES: Something special for unix you won't use in most cases. From the docs:

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

  • OTHER_FILES: Files, that are part of you project, but not of the "build". This can be things like a readme, build hints, or any other stuff, that does not fit into any other categories
  • RESOURCES: .qrc-files, that will be compiled into the application.

Regarding the usage of those three with QML:
You can basicly use DISTFILES or OTHER_FILES for other files. In QtCreator the appear in a node as other files. These two are exchangeable for most developers. The Qt examples are local project, thus either they don't require a resource or have both, i.e. you can find the QML-files in for example OTHER_FILES and RESOURCES.

For QML files, you should always use RESOURCES, to make sure they are within your binary.

0

Speaking of DISTFILES , you can try it yourself.

Assuming you are using Qt on Windows. Here is a very simple qmake project file project.pro:

TEMPLATE = app

DISTFILES += "C:\Windows\explorer.exe"

qmake it, and you can find the following statements in generated Makefile.Debug and Makefile.Release:

DIST          = C:\Windows\explorer.exe

...

dist:
    $(ZIP) project.zip $(SOURCES) $(DIST) project.pro
    ...

The target dist is one of the standard targets. I learned it from makefile - What is the difference between make and make dist? - Stack Overflow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.