Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-80145

QmlCache generated although project doesn't use Qml (but has .js files in resources)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • 5.12.5
    • Build tools: qmake
    • None

    Description

      When having a .js file in the resources and compiling the (qmake-based) project in release mode, qmake generates a QML cache file with a precompiled version of the .js file (I think - I never got in touch with this feature). However, if a project doesn't use Qml, this leads to a linker error since the generated qmlcache_loader.cpp calls some interal Qml registration functions.

      Besides the question, wether or not all .js files in the resource systems should be precompiled during compile time of the project - independently of wether or not they are actually used in the Qml engine later at runtime, or "just" resources for some other reason (like in my case) - it only makes sense to actually generate the QmlCache / precompile the js files if the project also makes use of the Qml module.

      I therefore request that this feature is only enabled if the project uses the Qml module. (At least I think that this might be a solution to this.)

      Minimal example (see also attachments):

      • Start with an empty Qt console application (qmake-based)
      • Add a resource file and add some arbitrary js file
      • Compile in release mode

      I suspect that the same happens when adding a .qml file to the resource system, but I didn't test it. In my case, the project contains a .js file for use in a web application, so its context is not the Qml world. I guess answering the question above, i.e. wether or not the .js is used in Qml, cannot be answered during compile time, so if the project uses Qml but also has some Qml-unrelated .js files, they are precompiled unneccessarily, but I guess this doesn't hurt so much (compared to the linker error when no Qml is used at all).

      Attachments

        1. main.cpp
          0.1 kB
        2. qmlcache_linker_error.pro
          0.9 kB
        3. test.js
          0.0 kB
        4. test.qrc
          0.1 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qtbuildsystem Qt Build System Team
              leemes Sebastian Lehmann
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes