[Qt-interest] moc warning and unresolved external symbol

Robert Escott robert at binarylogic.co.za
Tue Jan 4 13:37:53 CET 2011


Something similar to this has happened to me as well if I've imported
existing files and then changed the class names contained within.

 

Try removing the Q_OBJECT macro, saving, and then adding it back, and saving
again. Failing that, try removing the header "Project.h", save your solution
then add it back as an existing file. 

 

For one or both of those methods, as soon as you save, the Generated Files
section should be updated.

 

From: qt-interest-bounces+robert=binarylogic.co.za at qt.nokia.com
[mailto:qt-interest-bounces+robert=binarylogic.co.za at qt.nokia.com] On Behalf
Of hazreti coolcuzu
Sent: 04 January 2011 14:14
To: qt-interest
Subject: [Qt-interest] moc warning and unresolved external symbol

 

Hi,

I have a base class, and two derived classes as follows:

class Project : public QObject
{

Q_OBJECT

public:

...

protected:

 

signals:

void nameChanged(QString&);

}

class ProjectVideo : public Project
{

Q_OBJECT
....

}

class ProjectImage : public Project
{

Q_OBJECT
.....

}

I am using Qt 4.7 with Visual Studio 2008. When I rebuild, or build, it
says. 

1>.\Project.h(0): Warning: No relevant classes found. No output generated.
.
.
.
1>Project.obj : error LNK2001: unresolved external symbol "public: virtual
struct QMetaObject const * __thiscall Project::metaObject(void)const "
(?metaObject at Project@@UBEPBUQMetaObject@@XZ)
1>Project.obj : error LNK2001: unresolved external symbol "public: virtual
void * __thiscall Project::qt_metacast(char const *)"
(?qt_metacast at Project@@UAEPAXPBD at Z)
1>moc_ProjectImage.obj : error LNK2001: unresolved external symbol "public:
virtual void * __thiscall Project::qt_metacast(char const *)"
(?qt_metacast at Project@@UAEPAXPBD at Z)
1>moc_ProjectVideo.obj : error LNK2019: unresolved external symbol "public:
virtual void * __thiscall Project::qt_metacast(char const *)"
(?qt_metacast at Project@@UAEPAXPBD at Z) referenced in function "protected: void
__thiscall ProjectVideo::onInvalidated(class QRect *)"
(?onInvalidated at ProjectVideo@@IAEXPAVQRect@@@Z)
1>Project.obj : error LNK2001: unresolved external symbol "public: virtual
int __thiscall Project::qt_metacall(enum QMetaObject::Call,int,void * *)"
(?qt_metacall at Project@@UAEHW4Call at QMetaObject@@HPAPAX at Z)
1>moc_ProjectImage.obj : error LNK2001: unresolved external symbol "public:
virtual int __thiscall Project::qt_metacall(enum QMetaObject::Call,int,void
* *)" (?qt_metacall at Project@@UAEHW4Call at QMetaObject@@HPAPAX at Z)
1>moc_ProjectVideo.obj : error LNK2001: unresolved external symbol "public:
virtual int __thiscall Project::qt_metacall(enum QMetaObject::Call,int,void
* *)" (?qt_metacall at Project@@UAEHW4Call at QMetaObject@@HPAPAX at Z)
1>Project.obj : error LNK2019: unresolved external symbol "protected: void
__thiscall Project::nameChanged(class QString &)"
(?nameChanged at Project@@IAEXAAVQString@@@Z) referenced in function "public:
void __thiscall Project::setName(class QString &)"
(?setName at Project@@QAEXAAVQString@@@Z)
1>moc_ProjectImage.obj : error LNK2001: unresolved external symbol "public:
static struct QMetaObject const Project::staticMetaObject"
(?staticMetaObject at Project@@2UQMetaObject@@B)
1>moc_ProjectVideo.obj : error LNK2001: unresolved external symbol "public:
static struct QMetaObject const Project::staticMetaObject"
(?staticMetaObject at Project@@2UQMetaObject@@B)


How can I solve this problem?



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110104/e3711ed7/attachment.html 


More information about the Qt-interest-old mailing list