Results 1 to 8 of 8

Thread: QOBJECT and undefined reference to vtable errors

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    stargazer Guest

    Default QOBJECT and undefined reference to vtable errors

    I've been working on a plugin to an third party application an have recently introduced a GUI dialogue module into the project. The problem is that I can't get around an error I am getting which is:

    undefined reference to 'vtable for StelModule'

    I have reduced my code down to the basics and have discovered that when I remove Q_OBJECT from the class definition within the hpp file the everything compiles Ok. Obviously because this is a GUI it will require Q_OBJECT.

    I've found a few posts on the subject via Google and it would appear that this is something to do with .moc files. Unfortunately things start to get rather confusing after that, but as far as I understand, QT 4.7.1 (2010.05) should manage this pretty much authormatically. I have seen references to including a .moc file in the .cpp file but there seem to be no .moc files being generated. Insetad I do see a moc_mymodule.cpp and moc_mymodule.o in the debug directory. I'm also confused about what, if anything, should be added to the makefile and the qmake.conf file?

    Here is my code:


    HPP file:

    Qt Code:
    1. #ifndef GPSLOCATOR_HPP
    2. #define GPSLOCATOR_HPP
    3.  
    4. #include "StelGui.hpp"
    5. #include "StelModule.hpp"
    6. #include "StelFader.hpp"
    7. #include "StelPluginInterface.hpp"
    8.  
    9. class QTimer;
    10. class QPixmap;
    11. class StelButton;
    12. class GpsLocatorDialog;
    13.  
    14.  
    15. //! Dynamically loaded plug-in
    16.  
    17. class GpsLocator : public StelModule
    18. {
    19. Q_OBJECT
    20. public:
    21. GpsLocator();
    22. virtual ~GpsLocator();
    23.  
    24. };
    25.  
    26. /* COMMENTED OUT FOR TESTING
    27.   virtual ~GpsLocator();
    28.   // Methods defined in StelModule class
    29.   virtual void init();
    30.   virtual void update(double deltaTime);
    31.   virtual void draw(StelCore* core);
    32.   virtual double getCallOrder(StelModuleActionName actionName) const;
    33. signals:
    34.  
    35. public slots:
    36. // void enableGpsLocator(bool b);
    37.  
    38. private:
    39.   //Toolbar button
    40.   QPixmap* pixmapHover;
    41.   QPixmap* pixmapOnIcon;
    42.   QPixmap* pixmapOffIcon;
    43.   StelButton* toolbarButton;
    44.  
    45.   // Dialog Window
    46.   GpsLocatorDialog* dialogWindow;
    47.  
    48. };
    49. */
    50.  
    51. //! This class is used by Qt to manage a plug-in interface
    52. class GpsLocatorStelPluginInterface : public QObject, public StelPluginInterface
    53. {
    54. Q_OBJECT
    55. Q_INTERFACES(StelPluginInterface)
    56. public:
    57. virtual StelModule* getStelModule() const;
    58. virtual StelPluginInfo getPluginInfo() const;
    59. };
    60.  
    61. #endif // GPSLOCATOR_HPP
    To copy to clipboard, switch view to plain text mode 


    CPP file:

    Qt Code:
    1. #include "gpslocator.hpp"
    2.  
    3. #include "StelApp.hpp"
    4. #include "StelCore.hpp"
    5. #include "StelFileMgr.hpp"
    6. #include "StelGui.hpp"
    7. #include "StelGuiItems.hpp"
    8. #include "StelLocaleMgr.hpp"
    9. #include "StelModuleMgr.hpp"
    10. #include "StelPainter.hpp"
    11.  
    12. #include <QAction>
    13. #include <QDebug>
    14. #include <QPixmap>
    15. #include <QString>
    16.  
    17.  
    18. //! This method is the one called automatically by the StelModuleMgr
    19. //! just after loading the dynamic library
    20. StelModule* GpsLocatorStelPluginInterface::getStelModule() const
    21. {
    22. // return new GpsLocator();
    23. return false;
    24. }
    25.  
    26. StelPluginInfo GpsLocatorStelPluginInterface::getPluginInfo() const
    27. {
    28. // Allow to load the resources when used as a static plugin
    29. // Q_INIT_RESOURCE(gpsLocatorRsc);
    30.  
    31. StelPluginInfo info;
    32. info.id = "GpsLocator";
    33. info.displayedName = "GPS Locator Plugin";
    34. info.authors = "Jan Chajecki";
    35. info.contact = "http://stellarium.org/";
    36. info.description = "Allows Stellarium co-ordinates to be updated from a GPS device";
    37. return info;
    38. }
    39.  
    40. Q_EXPORT_PLUGIN2(GpsLocator, GpsLocatorStelPluginInterface)
    41.  
    42.  
    43. //! Constructor
    44. GpsLocator::GpsLocator()
    45. {
    46. // setObjectName("GpsLocator");
    47. }
    48.  
    49. //! Destructor
    50. GpsLocator::~GpsLocator()
    51. {
    52. }
    To copy to clipboard, switch view to plain text mode 
    Can anyone clearify what I need to do to get rid of this error please?
    Last edited by stargazer; 11th January 2011 at 17:11.

Similar Threads

  1. Qt Undefined Reference to vtable
    By ctote in forum Qt Programming
    Replies: 18
    Last Post: 24th February 2010, 22:24
  2. undefined reference to vtable in Threads.
    By prasanth.nvs in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 20th February 2009, 10:19
  3. Undefined reference to 'vtable for XXX'
    By Sheng in forum Qt Programming
    Replies: 4
    Last Post: 17th October 2008, 15:59
  4. undefined reference to vtable
    By renjithmamman in forum Qt Programming
    Replies: 5
    Last Post: 2nd July 2006, 04:23
  5. Replies: 2
    Last Post: 30th June 2006, 18:42

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.