Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. [Solved] Getting error compiling one of the tutorial examples
Forum Updated to NodeBB v4.3 + New Features

[Solved] Getting error compiling one of the tutorial examples

Scheduled Pinned Locked Moved Installation and Deployment
6 Posts 3 Posters 4.6k 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.
  • T Offline
    T Offline
    theuser
    wrote on last edited by
    #1

    hi, im trying to compile part 13 or the "official" qt tutorial(http://doc.trolltech.com/4.3/tutorial-t13.html) but doing so gives me the following error:
    "undefined reference to `vtable for Gameboard" while refering to this part of the code:
    @
    class GameBoard : public QWidget
    {
    Q_OBJECT@

    (its the first part of the gameboard.h file)

    im using qtcreator and the other parts compiled without any errors.
    Do you know what i did wrong? I simply copied the given source code and compiled

    1 Reply Last reply
    0
    • A Offline
      A Offline
      anselmolsm
      wrote on last edited by
      #2

      Ok, this is old, but this error is not related with the age of the tutorial (BTW, Qt 4.7 tutorials are "here":http://doc.trolltech.com/4.7/tutorials.html).

      How did you build the example? Did you try to run qmake again, then make?

      Anselmo L. S. Melo (anselmolsm)

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

        Did you add all the source files to your .pro file? The error comes from the linker, and it's likely that it's caused by a non-compiled source file.

        See a discussion of that error message here: http://bytes.com/topic/c/answers/161894-undefined-reference-vtable

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

        1 Reply Last reply
        0
        • A Offline
          A Offline
          anselmolsm
          wrote on last edited by
          #4

          theuser, I've just checked here, doing

          @
          qmake -project
          qmake
          make
          @

          this example compiled successfully. Reading the tutorial, I found that the class GameBoard is included in the project now and as I suspected, the build error you experienced happened because moc did not evaluate GameBoard yet. It's needed because GameBoard inherits QObject (via QWidget) and declares its own slots - moc is the "Qt Meta Object Compiler":http://doc.trolltech.com/4.7/moc.html, the guy who deals with Q_OBJECT stuff.

          Anselmo L. S. Melo (anselmolsm)

          1 Reply Last reply
          0
          • T Offline
            T Offline
            theuser
            wrote on last edited by
            #5

            thank you, i ran qmake once and compiled afterwards and now it works just fine :)

            edit: ah and thank you for the link to the newer tutorials i didnt know the one i worked with was "out of date"(though i guess the basic concepts are still the same)

            1 Reply Last reply
            0
            • A Offline
              A Offline
              anselmolsm
              wrote on last edited by
              #6

              [quote author="theuser" date="1291768946"]edit: ah and thank you for the link to the newer tutorials i didnt know the one i worked with was "out of date"(though i guess the basic concepts are still the same)[/quote]

              Indeed, the concepts are still the same. Also, it is a Qt 4 example so it is expected to work with Qt 4.7 too.

              I just pointed it's old because I could not find in the Qt 4.7 sources :-P

              Anselmo L. S. Melo (anselmolsm)

              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