[Solved] Qt "forgets" to link one of my "moc_MyClass.o" objects.
-
The source file is clearly in the project, among the rest of my classes.
I have Q_OBJECT defined for the class, like the rest of my Qt Classes.
My class compiles with the rest of the classes. Yet, the linker fails on the vtable for the constructor/destructor for my class. Checking the linker command: I can clearly see the moc_MyClass.o is missing from the linker command line.
How can that be? why is it left out?
-
Actually, the moc_MYCLASS.cpp is never created or built.
Why? It's in the project's headers and sources, has Q_OBJECT, and it just like any other class in my project.
Why won't moc get generated or built for my class? I narrowed the class down to simplest 'bare bones', and it passes compilation, a moc is never created though
-
Troubling resolution: removed the files(s) from my project, and added them back again. the moc is now generated. This is clearly a Qt "project cancer" bug.
-
What does [Bypasses] mean?
-
[Bypassed] - will correct.
-
Would [Solved] be more appropriate (and standard), perhaps?
-
Perhaps you're right.
-
I had a similar issue and I simply saved (ie., touch) my .pro file and that seemed to work.
-
I run into the same problems now and then. I usually solve it by doing a full rebuild (clean the project, re-run qmake (important!), completely rebuild the project). This way you ensure that qmake catches up all the changes and adds the necessary build steps (moc, uic) to the Makefile.
-
Its interesting because in this one instance a full clean and even restart of QtCreator did not fix it, it was not until I touched the .pro file that it finally worked. If in doubt, touch the .pro file then do as Volker says. ;)
-
In this case forcing a run of qmake should do the trick.