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. Problem with moc_* file
Forum Updated to NodeBB v4.3 + New Features

Problem with moc_* file

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 3.7k 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.
  • H Offline
    H Offline
    halftone
    wrote on last edited by
    #1

    I use QT with vs2008, I suffered the following problem for quite a lot of times, never found the reason and the method to slove it.

    Sometimes I write a new class with Q_OBJECT declared in it, the project runs well, then I do some changes to the class(very small changes), the moc_* file which the compiler generated is empty! so link error appears like this:

    error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall MainWindow::metaObject(void)const " (?metaObject@MainWindow@@UBEPBUQMetaObject@@XZ)
    …………

    So I remove all the changes, but the situation doesn't change, the moc_* file remains to be empty!

    I really want to know why?! Thank you very much for any possible answer and attention!

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      I haven't seen this behavior. What I do see often is

      • Adding a header file with Q_OBJECT in the class definition doesn't get visual studio to do the moc step

      • Adding or removing Q_OBJECT from the header file doesn't trigger the moc step

      Remove and add the header file again works around both of these. Maybe you should try your luck on it :). If that fails and it's a non-proprietary project you could post it here (or somewhere at least) so people can have a look at the project settings. (zipped of course)

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

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

      1 Reply Last reply
      0
      • S Offline
        S Offline
        steno
        wrote on last edited by
        #3

        I never have a problem with VS2008 when using the Qt addon. The addon is great, does the pre-build step for you and also adds the moc file to the project. It's worth checking out.

        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