Results 1 to 13 of 13

Thread: VTABLE - issue

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default VTABLE - issue

    Hello forum,

    i believe this issue is already discussed here. But i could not figure out any reason of the following error related to vtable:


    Qt Code:
    1. ../../Build/H3DSceneEditor/Debug/H3DSceneHierarchy.o: In function `~H3DSceneHierarchy':
    2. /home/sajjad/Documents/H3DFunctionalSoFar/H3D/src/H3DSceneEditor/H3DSceneHierarchy.cpp:19: undefined reference to `vtable for H3DSceneHierarchy'
    3. /home/sajjad/Documents/H3DFunctionalSoFar/H3D/src/H3DSceneEditor/H3DSceneHierarchy.cpp:19: undefined reference to `vtable for H3DSceneHierarchy'
    4. /home/sajjad/Documents/H3DFunctionalSoFar/H3D/src/H3DSceneEditor/H3DSceneHierarchy.cpp:19: undefined reference to `vtable for H3DSceneHierarchy'
    5. ../../Build/H3DSceneEditor/Debug/H3DSceneHierarchy.o: In function `H3DSceneHierarchy':
    6. /home/sajjad/Documents/H3DFunctionalSoFar/H3D/src/H3DSceneEditor/H3DSceneHierarchy.cpp:13: undefined reference to `vtable for H3DSceneHierarchy'
    7. /home/sajjad/Documents/H3DFunctionalSoFar/H3D/src/H3DSceneEditor/H3DSceneHierarchy.cpp:13: undefined reference to `vtable for H3DSceneHierarchy'
    8. collect2: ld returned 1 exit status
    9. make[2]: *** [../../bin/H3Dd] Error 1
    10. make[2]: Leaving directory `/home/sajjad/Documents/H3DFunctionalSoFar/H3D/src/H3DSceneEditor'
    11. make[1]: *** [sub-H3DSceneEditor-make_default-ordered] Error 2
    To copy to clipboard, switch view to plain text mode 



    Qt Code:
    1. class H3DSceneHierarchy : public QObject
    2. {
    3. Q_OBJECT
    4. public:
    5.  
    6. H3DSceneHierarchy(QObject *parent = 0);
    7.  
    8. ~H3DSceneHierarchy();
    9.  
    10. }
    To copy to clipboard, switch view to plain text mode 


    [CODE]


    And in the source file


    Qt Code:
    1. H3DSceneHierarchy::H3DSceneHierarchy(QObject *parent)
    2. : QObject(parent)
    3. {
    4.  
    5. }
    6.  
    7.  
    8. H3DSceneHierarchy::~H3DSceneHierarchy()
    9. {
    10.  
    11. }
    To copy to clipboard, switch view to plain text mode 



    Is there anything wrong in the above code ?


    Regards
    Sajjad

  2. #2
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: VTABLE - issue

    First of all I think you are missing a semicolon after class declaration, then make sure you have header and source file for the class and correct include.

    You could also write which are the error lines. Cause I can't see what line number refers to.

  3. #3
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: VTABLE - issue

    Semicolon after class declaration is missing, nothing more wrong with this I think.

    ---
    edit: too slow
    btw. line 19:
    H3DSceneHierarchy.cpp:19: undefined reference to `vtable for H3DSceneHierarchy'
    If you keep getting this error after adding the semicolon, make sure moc is generated for this header ( add it to HEADERS list in .pro file, or run moc yourself )

  4. #4
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: VTABLE - issue

    Also, do a 'make clean' followed by a new run of 'qmake' and 'make'. Fouled vtables are often caused by failure to invoke qmake, which generates Qt's metacode, and by failure to clean a build, which causes mismatched source code components to be compiled together.

  5. #5
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: VTABLE - issue

    Thanks for such a quick reply!!


    1. I included the semicolon that i missed.

    2. Ran "make clean && make"


    And unfortunately the same error . I have also checked the .pro file here i already have the header and source file defined.


    Any other hint to resolve this?


    Qt Code:
    1. #ifndef H3DSCENEHIERARCHY_H
    2. #define H3DSCENEHIERARCHY_H
    3.  
    4. #include <iostream>
    5. #include <vector>
    6.  
    7. #include <QObject>
    8. #include <QString>
    9.  
    10. //#include "H3DSceneHierarchyObserver.h"
    11.  
    12. class H3DNodeData;
    13. class H3DRouteLink;
    14. class H3DProperty;
    15.  
    16. //!H3DSceneHierarchy is alike the ProcessorNetwork in the Voreen API
    17. class H3DSceneHierarchy : public QObject /* Observable<H3DSceneHierarchyObserver> */
    18. {
    19. Q_OBJECT
    20. public:
    21.  
    22. H3DSceneHierarchy(QObject *parent = 0);
    23.  
    24. ~H3DSceneHierarchy();
    25.  
    26. private:
    27.  
    28.  
    29.  
    30. //store the list of nodes in the scene hierarchy
    31. //which has been dragged into the editor
    32. std::vector<H3DNodeData*> m_nodeList;
    33.  
    34.  
    35. //!store the list of routing links in the scene hierarchy
    36. std::vector<H3DRouteLink*> m_routeLinkList;
    37.  
    38.  
    39.  
    40. };
    41.  
    42. #endif // H3DSCENEHIERARCHY_H
    To copy to clipboard, switch view to plain text mode 

    The separate .cpp file contanis the following:


    Qt Code:
    1. #include "H3DSceneHierarchy.h"
    2. #include "H3DNodeData.h"
    3.  
    4.  
    5. #include "H3DRouteLink.h"
    6. #include "H3DProperty.h"
    7.  
    8.  
    9. #include <algorithm>
    10.  
    11.  
    12. H3DSceneHierarchy::H3DSceneHierarchy(QObject *parent)
    13. : QObject(parent)
    14. {
    15.  
    16. }
    17.  
    18.  
    19. H3DSceneHierarchy::~H3DSceneHierarchy()
    20. {
    21. /*!
    22.   * remove all the nodes, hierarchy and route connections from the scene
    23.   * hierarchy and deletes them
    24.   */
    25. //clear();
    26. }
    To copy to clipboard, switch view to plain text mode 


    Regards
    Sajjadul

  6. #6
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: VTABLE - issue

    Since you are using Q_OBJECT, have you run qmake?

  7. #7
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: VTABLE - issue

    did you run qmake?

  8. #8
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: VTABLE - issue

    I am using QtCreator to edit the project.


    I just closed it down and started again. And now it works!!!


    Thanks all of you.


    Any explanation of it?


    Regards
    Sajjad

  9. #9
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: VTABLE - issue

    What's the OS are you using?

  10. #10
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: VTABLE - issue

    Ubuntu 8.10

    Should it be a reason?

  11. #11
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: VTABLE - issue

    I guess not, but if I remember correctly something like that happened to me before, so next time it happens I want to know if that is just system related. Unfortunately I have no idea what system I used cause I do programming on OS X, Vista, Kubuntu simultaneously...

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: VTABLE - issue

    The reason is you didn't run qmake as a number of people already pointed out.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #13
    Join Date
    Jun 2011
    Location
    Rhode Island
    Posts
    16
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: VTABLE - issue

    Make sure all methods defined in the header (Especially the slots and signals as they are Q_OBJECT and Qmake specific) have an implementation in your source file. If you do not implement a method that is Q_OBJECT specific (ie. signals and slots) you will get this error.

Similar Threads

  1. undefined reference to 'vtable ...'
    By GUIman in forum Newbie
    Replies: 5
    Last Post: 10th March 2011, 01:38
  2. Qt Undefined Reference to vtable
    By ctote in forum Qt Programming
    Replies: 18
    Last Post: 24th February 2010, 22:24
  3. Undefined reference to 'vtable for XXX'
    By Sheng in forum Qt Programming
    Replies: 4
    Last Post: 17th October 2008, 15:59
  4. vtable problems
    By high_flyer in forum Qt Programming
    Replies: 6
    Last Post: 3rd September 2007, 13:52
  5. undefined reference to vtable
    By renjithmamman in forum Qt Programming
    Replies: 5
    Last Post: 2nd July 2006, 04:23

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.