Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. MinGW32-make and Q_INIT_RESOURCE
Qt 6.11 is out! See what's new in the release blog

MinGW32-make and Q_INIT_RESOURCE

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 5.0k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rapidrain
    wrote on last edited by
    #1

    I'm writing one of the examples supplied by Qt, FridgeMagnets, however I must compile it with g++ and use MinGW32-make.
    the initial statement Q_INIT_RESOURCE(fridgemagnets); doesn't work.
    it will not recognise the fridgemagnets.qrc file and do the things it's supposed to do.
    Must I add a magic word to my compilation/link commands??

    
    #include <QApplication>
    #include "DragWidget.h"
    
    int main(int argc, char *argv[])
    {
        Q_INIT_RESOURCE(fridgemagnets);
    
        QApplication app(argc, argv);
    //#ifdef QT_KEYPAD_NAVIGATION
    //    QApplication::setNavigationMode(Qt::NavigationModeCursorAuto);
    //#endif
        DragWidget window;
    
    //#ifdef Q_OS_SYMBIAN
    //    bool smallScreen = true;
    //#else
    //    bool smallScreen = QApplication::arguments().contains("-small-screen");
    //#endif
    
    //    if (smallScreen)
    //        window.showFullScreen();
    //    else
        window.show();
    
        return app.exec();
    }
    

    make file :
    Link objects obj/Debug/FridgeMagnetsd.o obj/Debug/DragLabeld.o obj/Debug/moc_DragLabeld.o obj/Debug/DragWidgetd.o obj/Debug/moc_DragWidgetd.o

    D:/MinGW/64/bin/g++ -Wl,-subsystem,windows -mthreads -o D:/Projects/FridgeMagnets/bin/Debug/FridgeMagnetsd.exe obj/Debug/FridgeMagnetsd.o obj/Debug/DragLabeld.o obj/Debug/moc_DragLabeld.o obj/Debug/DragWidgetd.o obj/Debug/moc_DragWidgetd.o -LD:/Qt64/qt-install/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lmingw32 -lqtmain -lQt5Widgets -lQt5Core -lQt5Gui
    obj/Debug/FridgeMagnetsd.o:

    D:\Projects\FridgeMagnets/src/FridgeMagnets.cpp:14: undefined reference to `qInitResources_fridgemagnets()'

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You should rather call Q_INIT_RESOURCE after creating your app object. Qt's internals are initialised after create an application object.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Rapidrain
        wrote on last edited by
        #3

        'fraid not SGaist.

        The original code from the examples folder of my Qt64 installation has the call before the creation of the QApplication object.

        And I moved it to after the creation of the QApplication object -- it still fails for the exact same reasons.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Which example is it ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • R Offline
            R Offline
            Rapidrain
            wrote on last edited by
            #5

            On my PC the example is located in :
            D:\Qt64\qt-install\examples\widgets\draganddrop\fridgemagnets

            kshegunovK 1 Reply Last reply
            0
            • R Rapidrain

              On my PC the example is located in :
              D:\Qt64\qt-install\examples\widgets\draganddrop\fridgemagnets

              kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on last edited by
              #6

              You don't use that macro if your resources are in the application. Also you don't use it with dynamic libraries unless you're loading it at runtime. You need that macro when your resources are in a static library or in a plugin, or in a library that's being loaded at runtime.

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply
              1
              • R Offline
                R Offline
                Rapidrain
                wrote on last edited by
                #7

                thanks kshegunov, now we're getting somewhere.
                A "library that's being loaded at runtime" would be a DLL, wouldn't it?
                I load the resource ( = a list of words in a txt file) with :

                QFile dictionaryFile("dictionary/words.txt");
                

                Is this statement indicative of :
                A: a library being loaded at runtime or
                B: a static library or
                C: a plugin or
                D: a dynamic load library
                E: none of the above

                ?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Answer E

                  It shows you are trying to load a file from a relative path on the hard drive.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  2

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved