Slot problems with QT, linker error
Question
Was wanting to ask about a linker error I keep getting. I installed QT and am using it on Visual Studio 2005. Basically whenever i try and declare a slot I get this linker error message.
Error 1 error LNK2019: unresolved external symbol "public: int __thiscall ipodGuiLoaderQT::hello(void)" (?hello@ipodGuiLoaderQT@@QAEHXZ) referenced in function "public: virtual int __thiscall ipodGuiLoaderQT::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@ipodGuiLoaderQT@@UAEHW4Call@QMetaObject@@HPAPAX@Z) moc_ipodguiloaderqt.obj
This usually suggests that I haven't included the correct header file. But I should have. Here's my code so far.
#ifndef IPODGUILOADERQT_H
#define IPODGUILOADERQT_H
#include <QtGui/QMainWindow>
#include <QtGui/QAction>
#include <QObject>
#include "ui_ipodguiloaderqt.h"
class ipodGuiLoaderQT : public QMainWindow
{
Q_OBJECT
public:
ipodGuiLoaderQT(QWidget *parent = 0, Qt::WFlags flags = 0);
~ipodGuiLoaderQT();
private:
Ui::ipodGuiLoaderQTClass ui;
QAction* blah;
public slots:
int hello();
};
#endif // IPODGUILOADERQT_H
Any help would be appreciated.
Solution
Error 1 error LNK2019: unresolved external symbol "public: int __thiscall ipodGuiLoaderQT::hello(void)"
The linker is clearly saying you that it couldn't find which is the definition of ipodGuiLoaderQT::hello(void)
. What you have as a part of the class ipodGuiLoaderQT
is just the declaration and check whether you have provided it's implementation (i.e., definition) in the corresponding source file and compiled it too.