[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
-
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.