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 11 Aug 2018, 10:58 last edited by aha_1980 8 Dec 2018, 11:07
    #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

    K 1 Reply Last reply 11 Aug 2018, 11:06
    0
    • Q Qt Enthusiast
      11 Aug 2018, 10:58

      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

      K Offline
      K Offline
      kshegunov
      Moderators
      wrote on 11 Aug 2018, 11:06 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
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 11 Aug 2018, 15:19 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 11 Aug 2018, 22:07 last edited by
          #4

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

          M 1 Reply Last reply 11 Aug 2018, 22:08
          0
          • Q Qt Enthusiast
            11 Aug 2018, 22:07

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

            M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 11 Aug 2018, 22:08 last edited by
            #5

            @Qt-Enthusiast
            Show code :)

            1 Reply Last reply
            1
            • Q Offline
              Q Offline
              Qt Enthusiast
              wrote on 11 Aug 2018, 22:57 last edited by Qt Enthusiast 8 Nov 2018, 22:59
              #6

              https://paste.ofcode.org/iphXzSpzkkML3d9wKAEftq

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

              K 1 Reply Last reply 12 Aug 2018, 09:05
              0
              • H Online
                H Online
                hskoglund
                wrote on 11 Aug 2018, 23:05 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
                  11 Aug 2018, 22:57

                  https://paste.ofcode.org/iphXzSpzkkML3d9wKAEftq

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

                  K Offline
                  K Offline
                  kshegunov
                  Moderators
                  wrote on 12 Aug 2018, 09:05 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

                  1/8

                  11 Aug 2018, 10:58

                  • Login

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