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. how to solve this the error undefined reference in this case
Forum Updated to NodeBB v4.3 + New Features

how to solve this the error undefined reference in this case

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 5 Posters 1.3k Views 4 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by aha_1980
    #1

    4.8.6/Linux5/x86_64/lib -o simpletreemodel main.o treeitem.o treemodel.o moc_treemodel.o qrc_simpletreemodel.o -L/in/qt-4.8.6/Linux5/x86_64/lib -lQtGui -L/in/qt-4.8.6/Linux5/x86_64/lib -L/usr/X11R6/lib -lQtCore -lpthread
    main.o: In function myclass::myclass(QObject*)': main.cpp:(.text+0x61f): undefined reference to vtable for myclass'
    main.o: In function myclass::~myclass()': main.cpp:(.text._ZN7myclassD2Ev[_ZN7myclassD5Ev]+0xb): undefined reference to vtable for myclass'
    main.o: In function myclass::~myclass()': main.cpp:(.text._ZN7myclassD0Ev[_ZN7myclassD5Ev]+0xb): undefined reference to vtable for myclass'
    collect2: ld returned 1 exit status
    make: *** [simpletreemodel] Error 1

    kshegunovK 1 Reply Last reply
    0
    • Q Qt Enthusiast

      4.8.6/Linux5/x86_64/lib -o simpletreemodel main.o treeitem.o treemodel.o moc_treemodel.o qrc_simpletreemodel.o -L/in/qt-4.8.6/Linux5/x86_64/lib -lQtGui -L/in/qt-4.8.6/Linux5/x86_64/lib -L/usr/X11R6/lib -lQtCore -lpthread
      main.o: In function myclass::myclass(QObject*)': main.cpp:(.text+0x61f): undefined reference to vtable for myclass'
      main.o: In function myclass::~myclass()': main.cpp:(.text._ZN7myclassD2Ev[_ZN7myclassD5Ev]+0xb): undefined reference to vtable for myclass'
      main.o: In function myclass::~myclass()': main.cpp:(.text._ZN7myclassD0Ev[_ZN7myclassD5Ev]+0xb): undefined reference to vtable for myclass'
      collect2: ld returned 1 exit status
      make: *** [simpletreemodel] Error 1

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      Show the declaration of myclass and the definition of myclass::myclass and myclass::~myclass.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      4
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        In addition to what @kshegunov wrote, did you add or remove the Q_OBJECT macro from your class ? If so you likely forgot to re-run qmake before building your application.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        4
        • Q Offline
          Q Offline
          Qt Enthusiast
          wrote on last edited by
          #4

          yes and if i put Q_OBJECT then i get this error do i have start from qmake again

          mrjjM 1 Reply Last reply
          0
          • Q Qt Enthusiast

            yes and if i put Q_OBJECT then i get this error do i have start from qmake again

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Qt-Enthusiast
            Show code :)

            1 Reply Last reply
            1
            • Q Offline
              Q Offline
              Qt Enthusiast
              wrote on last edited by Qt Enthusiast
              #6

              https://paste.ofcode.org/iphXzSpzkkML3d9wKAEftq

              What I am missing .Event if I rerun the from qmake , I am getting the error

              kshegunovK 1 Reply Last reply
              0
              • hskoglundH Offline
                hskoglundH Offline
                hskoglund
                wrote on last edited by
                #7

                Hi, try to move the class definition ( class myclass: public QObject..) into a .h file. The moc compiler will be more happy.

                1 Reply Last reply
                3
                • Q Qt Enthusiast

                  https://paste.ofcode.org/iphXzSpzkkML3d9wKAEftq

                  What I am missing .Event if I rerun the from qmake , I am getting the error

                  kshegunovK Offline
                  kshegunovK Offline
                  kshegunov
                  Moderators
                  wrote on last edited by
                  #8

                  @Qt-Enthusiast said in how to solve this the error undefined referene in this case:

                  What I am missing.

                  Nothing as far as I can see. Try what @hskoglund suggested and do a full rebuild.

                  Read and abide by the Qt Code of Conduct

                  1 Reply Last reply
                  1

                  • Login

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