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. [Solved] Qt "forgets" to link one of my "moc_MyClass.o" objects.
Forum Updated to NodeBB v4.3 + New Features

[Solved] Qt "forgets" to link one of my "moc_MyClass.o" objects.

Scheduled Pinned Locked Moved General and Desktop
11 Posts 4 Posters 3.2k Views 1 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
    ronM71
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • R Offline
      R Offline
      ronM71
      wrote on last edited by
      #2

      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

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

        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.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mlong
          wrote on last edited by
          #4

          What does [Bypasses] mean?

          Software Engineer
          My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

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

            [Bypassed] - will correct.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mlong
              wrote on last edited by
              #6

              Would [Solved] be more appropriate (and standard), perhaps?

              Software Engineer
              My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

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

                Perhaps you're right.

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mirswith
                  wrote on last edited by
                  #8

                  I had a similar issue and I simply saved (ie., touch) my .pro file and that seemed to work.

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    goetz
                    wrote on last edited by
                    #9

                    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.

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mirswith
                      wrote on last edited by
                      #10

                      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. ;)

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        goetz
                        wrote on last edited by
                        #11

                        In this case forcing a run of qmake should do the trick.

                        http://www.catb.org/~esr/faqs/smart-questions.html

                        1 Reply Last reply
                        0

                        • Login

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