stargazer
11th January 2011, 17:53
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:
#ifndef GPSLOCATOR_HPP
#define GPSLOCATOR_HPP
#include "StelGui.hpp"
#include "StelModule.hpp"
#include "StelFader.hpp"
#include "StelPluginInterface.hpp"
class QTimer;
class QPixmap;
class StelButton;
class GpsLocatorDialog;
//! Dynamically loaded plug-in
class GpsLocator : public StelModule
{
Q_OBJECT
public:
GpsLocator();
virtual ~GpsLocator();
};
/* COMMENTED OUT FOR TESTING
virtual ~GpsLocator();
// Methods defined in StelModule class
virtual void init();
virtual void update(double deltaTime);
virtual void draw(StelCore* core);
virtual double getCallOrder(StelModuleActionName actionName) const;
signals:
public slots:
// void enableGpsLocator(bool b);
private:
//Toolbar button
QPixmap* pixmapHover;
QPixmap* pixmapOnIcon;
QPixmap* pixmapOffIcon;
StelButton* toolbarButton;
// Dialog Window
GpsLocatorDialog* dialogWindow;
};
*/
//! This class is used by Qt to manage a plug-in interface
class GpsLocatorStelPluginInterface : public QObject, public StelPluginInterface
{
Q_OBJECT
Q_INTERFACES(StelPluginInterface)
public:
virtual StelModule* getStelModule() const;
virtual StelPluginInfo getPluginInfo() const;
};
#endif // GPSLOCATOR_HPP
CPP file:
#include "gpslocator.hpp"
#include "StelApp.hpp"
#include "StelCore.hpp"
#include "StelFileMgr.hpp"
#include "StelGui.hpp"
#include "StelGuiItems.hpp"
#include "StelLocaleMgr.hpp"
#include "StelModuleMgr.hpp"
#include "StelPainter.hpp"
#include <QAction>
#include <QDebug>
#include <QPixmap>
#include <QString>
//! This method is the one called automatically by the StelModuleMgr
//! just after loading the dynamic library
StelModule* GpsLocatorStelPluginInterface::getStelModule() const
{
// return new GpsLocator();
return false;
}
StelPluginInfo GpsLocatorStelPluginInterface::getPluginInfo() const
{
// Allow to load the resources when used as a static plugin
// Q_INIT_RESOURCE(gpsLocatorRsc);
StelPluginInfo info;
info.id = "GpsLocator";
info.displayedName = "GPS Locator Plugin";
info.authors = "Jan Chajecki";
info.contact = "http://stellarium.org/";
info.description = "Allows Stellarium co-ordinates to be updated from a GPS device";
return info;
}
Q_EXPORT_PLUGIN2(GpsLocator, GpsLocatorStelPluginInterface)
//! Constructor
GpsLocator::GpsLocator()
{
// setObjectName("GpsLocator");
}
//! Destructor
GpsLocator::~GpsLocator()
{
}
Can anyone clearify what I need to do to get rid of this error please?
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:
#ifndef GPSLOCATOR_HPP
#define GPSLOCATOR_HPP
#include "StelGui.hpp"
#include "StelModule.hpp"
#include "StelFader.hpp"
#include "StelPluginInterface.hpp"
class QTimer;
class QPixmap;
class StelButton;
class GpsLocatorDialog;
//! Dynamically loaded plug-in
class GpsLocator : public StelModule
{
Q_OBJECT
public:
GpsLocator();
virtual ~GpsLocator();
};
/* COMMENTED OUT FOR TESTING
virtual ~GpsLocator();
// Methods defined in StelModule class
virtual void init();
virtual void update(double deltaTime);
virtual void draw(StelCore* core);
virtual double getCallOrder(StelModuleActionName actionName) const;
signals:
public slots:
// void enableGpsLocator(bool b);
private:
//Toolbar button
QPixmap* pixmapHover;
QPixmap* pixmapOnIcon;
QPixmap* pixmapOffIcon;
StelButton* toolbarButton;
// Dialog Window
GpsLocatorDialog* dialogWindow;
};
*/
//! This class is used by Qt to manage a plug-in interface
class GpsLocatorStelPluginInterface : public QObject, public StelPluginInterface
{
Q_OBJECT
Q_INTERFACES(StelPluginInterface)
public:
virtual StelModule* getStelModule() const;
virtual StelPluginInfo getPluginInfo() const;
};
#endif // GPSLOCATOR_HPP
CPP file:
#include "gpslocator.hpp"
#include "StelApp.hpp"
#include "StelCore.hpp"
#include "StelFileMgr.hpp"
#include "StelGui.hpp"
#include "StelGuiItems.hpp"
#include "StelLocaleMgr.hpp"
#include "StelModuleMgr.hpp"
#include "StelPainter.hpp"
#include <QAction>
#include <QDebug>
#include <QPixmap>
#include <QString>
//! This method is the one called automatically by the StelModuleMgr
//! just after loading the dynamic library
StelModule* GpsLocatorStelPluginInterface::getStelModule() const
{
// return new GpsLocator();
return false;
}
StelPluginInfo GpsLocatorStelPluginInterface::getPluginInfo() const
{
// Allow to load the resources when used as a static plugin
// Q_INIT_RESOURCE(gpsLocatorRsc);
StelPluginInfo info;
info.id = "GpsLocator";
info.displayedName = "GPS Locator Plugin";
info.authors = "Jan Chajecki";
info.contact = "http://stellarium.org/";
info.description = "Allows Stellarium co-ordinates to be updated from a GPS device";
return info;
}
Q_EXPORT_PLUGIN2(GpsLocator, GpsLocatorStelPluginInterface)
//! Constructor
GpsLocator::GpsLocator()
{
// setObjectName("GpsLocator");
}
//! Destructor
GpsLocator::~GpsLocator()
{
}
Can anyone clearify what I need to do to get rid of this error please?