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

Qt 5.10.1, MinGW 7.2.0, Error: "undefined reference to ..." defined Qt signals



  • Disclosure: I am not certain whether this question is a Qt question, MinGW linker question, or a MinGW library question.

    First, some background.

    I have some apps that I have successfully built on prior versions of Qt (5.9x, 5.10.0), using both the Qt Creator environment and using a recent MinGW (i686) compliler and linker. It is my understanding (but feel free to correct me) that both Qt Creator and the i686 MinGW compiler build 32-bit executables.

    However, I now have an app that ought to benefit from a 64-bit executable (large datasets requiring higher numeric precision). I presume that means I need the x86_64 complier from MinGW and a corresponding 64-bit build of Qt. I took this as motivation to install the most recent versions of Qt, MinGW, and various other libraries for numeric processing and such stuff. I have built and tested all of the various pieces required.

    Unfortunately, I am stuck when I try to incorporate a library of Qt widgets that I routinely use.

    For reasons driven by non-Qt parts of all this, I have found it beneficial generally to work outside of Qt Creator and use mingw32-make to build the apps.

    Now the present problem/symptom.

    A test app requires several Qt widgets, qtwidg-1.cpp, qtwidg-2.cpp, etc. I use two different methods to build the final app - one works, the other doesn't.

    Successful method: 1) moc.exe to build the required moc_qtwidg-1.cpp, moc_qtwidg2.cpp, etc. 2) Compile all .cpp files with g++. Use the g++ linker is used to pull everthing into app.exe. The resulting app works.

    However, since all of the qtwidg-x.cpp are used by many apps, I want to put them into a re-usable library, which leads to the other method.

    Unsuccessful method: 1) same as above. 2) same as above 3) create a library with the same .o files as above using ar.exe. 4) Tell the g++ linker to load that library. In the past, this method has worked - now it doesn't.

    The errors are of the form "undefined reference to `myQLE::escape(QWidget*)" where "escape" is a Qt signal defined in myqle.hpp. Each and every signal is marked as an undefined reference.

    Does anyone have a suggestion where to start looking for the underlying source of this behavior?


Log in to reply