PDA

View Full Version : Linker errors with Q_OBJECT



dustin034
13th May 2010, 18:46
I have been creating Qt applications for some time and am familiar with the steps necessary in order to integrate Qt into a project, however, I am currently experiencing some problems I have not seen before.

When I attempt to add the Q_OBJECT keyword into my class, I get linker errors as follows:

error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall ClientGUI::metaObject(void)const " (?metaObject@ClientGUI@MPT@ar@@UBEPBUQMetaObject@@ XZ)
1>ClientGUI.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall ClientGUI::qt_metacast(char const *)" (?qt_metacast@ClientGUI@MPT@ar@@UAEPAXPBD@Z)
1>ClientGUI.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall ClientGUI::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@ClientGUI@MPT@ar@@UAEHW4Call@QMetaOb ject@@HPAPAX@Z)

When I take out the Q_OBJECT tag I then get unresolved external linker errors for my signals. When I have seen this in the past it was usually because I forgot to add the header files to be MOCed, but I have made sure that this is in fact happening in my project. I have also made sure my class is deriving from QObject.

I am using CMake 2.8 and the CMake file is virtually identical to another project I have done with Qt that is working fine.

Any help is appreciated,
Dustin

Lykurg
13th May 2010, 18:58
Hi,

I had sometimes problems with that, if I had forgotten to absolutely clean my project and build all new. Unforunatelly I can't say more.

dustin034
13th May 2010, 19:14
Actually, I just fixed the problem. The problem was that although I was indeed MOCing the headers I needed to, I was not including those MOCed .cxx files in the actual project includes in CMake. Thanks for the help anyways.:)