Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to use QMAKE_EXTRA_COMPILERS to run rcc -binary



  • Hi

    I want to create a project that consists of resources and the build step should simply run the rcc command to build a binary resource file.

    rcc -binary -no-compress resources.qrc -o resources.rcc
    

    I've been trying to accomplish this with QMAKE_EXTRA_COMPILERS, but I would appreciate some pointers.

    TEMPLATE = lib
    CONFIG += console
    CONFIG -= app_bundle
    
    resource_build.input = RESOURCES
    resource_build.commands = rcc -binary -no-compress ${QMAKE_FILE_NAME} -o $$OUT_PWD/test.rcc
    resource_build.config += no_link
    QMAKE_EXTRA_COMPILERS += resource_build
    
    RESOURCES += \
            res.qrc
    

    Thanks.


  • Moderators

    @rincewind said in How to use QMAKE_EXTRA_COMPILERS to run rcc -binary:

    RESOURCES += \

    This will run rcc automatically already.

    Are you getting any errors? It's complaining that no C++ files are being compiled or something?



  • For anybody else trying to do this, this at least generates the binary resource file.

    TEMPLATE = lib
    CONFIG += console
    CONFIG -= app_bundle
    
    resource_build.input = OTHER_FILES
    resource_build.output = out.rcc
    resource_build.depends = $$PWD/res.qrc
    resource_build.commands = rcc -binary -no-compress ${QMAKE_FILE_NAME} -o $$OUT_PWD/out.rcc
    resource_build.config += no_link
    QMAKE_EXTRA_COMPILERS += resource_build
    
    OTHER_FILES += \
            res.qrc
    

    I still get errors due to the linker not being happy with the rcc file. I obviously don't want to link against it.

    According the documentation:
    no_link — the files that are created should not be added to OBJECTS — i.e., they are not compiled code which should be linked,


  • Lifetime Qt Champion

    @rincewind As @sierdzio said: why don't you use

    RESOURCES += \
    

    ?



  • @jsulm
    Because it would run the normal rcc command to generate cpp files, which is not what I want as I explained in my message and specified in the title...


  • Lifetime Qt Champion

    Hi,

    Do you have the same issue if you follow the example provided here and just add the no_link option ?


Log in to reply