Results 1 to 3 of 3

Thread: Linker errors with Q_OBJECT

  1. #1
    Join Date
    May 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Linker errors with Q_OBJECT

    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:
    Qt Code:
    1. error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall ClientGUI::metaObject(void)const " (?metaObject@ClientGUI@MPT@ar@@UBEPBUQMetaObject@@XZ)
    2. 1>ClientGUI.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall ClientGUI::qt_metacast(char const *)" (?qt_metacast@ClientGUI@MPT@ar@@UAEPAXPBD@Z)
    3. 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@QMetaObject@@HPAPAX@Z)
    To copy to clipboard, switch view to plain text mode 

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Linker errors with Q_OBJECT

    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.

  3. #3
    Join Date
    May 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Linker errors with Q_OBJECT

    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.

Similar Threads

  1. linker errors from MinGW 4.4.0 for Qt 4.6.2
    By planetLars in forum Qt Tools
    Replies: 1
    Last Post: 15th April 2010, 20:30
  2. Q_OBJECT macro and link errors
    By pscheven in forum Qt Programming
    Replies: 4
    Last Post: 21st March 2008, 13:23
  3. please help with linker errors
    By jimboqt in forum Qt Programming
    Replies: 1
    Last Post: 5th July 2007, 09:49
  4. Linker errors!!
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 25th April 2006, 08:14
  5. Linker Errors
    By MarkoSan in forum Qt Programming
    Replies: 5
    Last Post: 7th March 2006, 18:30

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.