Results 1 to 4 of 4

Thread: problems with linking.... ??

  1. #1

    Default problems with linking.... ??

    Hi,

    I had a programm with 2 forms. This all worked. Now i tried to move the code and the form into a dll. When compiling and linking now, i get error LNK2001.

    The complete output is here :

    ------ Build started: Project: logconsole, Configuration: Debug Win32 ------

    Deleting intermediate files and output files for project 'logconsole', configuration 'Debug|Win32'.
    Moc'ing logconsole.h...
    Uic'ing logconsole.ui...
    Compiling...
    logconsole.cpp
    c:\Qt\4.1.3\include\QtCore\arch\../../../src\corelib\arch\windows\arch\qatomic.h(131) : warning C4311: 'reinterpret_cast' : pointer truncation from 'void *' to 'long'
    c:\Qt\4.1.3\include\QtCore\arch\../../../src\corelib\arch\windows\arch\qatomic.h(131) : warning C4311: 'reinterpret_cast' : pointer truncation from 'void *' to 'long'
    c:\Qt\4.1.3\include\QtCore\arch\../../../src\corelib\arch\windows\arch\qatomic.h(131) : warning C4312: 'reinterpret_cast' : conversion from 'long' to 'void *' of greater size
    c:\Qt\4.1.3\include\QtCore\arch\../../../src\corelib\arch\windows\arch\qatomic.h(143) : warning C4311: 'reinterpret_cast' : pointer truncation from 'void *' to 'long'
    c:\Qt\4.1.3\include\QtCore\arch\../../../src\corelib\arch\windows\arch\qatomic.h(143) : warning C4312: 'reinterpret_cast' : conversion from 'long' to 'void *' of greater size
    Microsoft Compiler detected
    Linking...
    Creating library ..\..\..\..\exe/lib/logconsole.lib and object ..\..\..\..\exe/lib/logconsole.exp
    logconsole.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const LogConsole::staticMetaObject" (?staticMetaObject@LogConsole@@2UQMetaObject@@B)
    logconsole.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall LogConsole::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@LogConsole@@UAEHW4Call@QMetaObject@@ HPAPAX@Z)
    logconsole.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall LogConsole::qt_metacast(char const *)" (?qt_metacast@LogConsole@@UAEPAXPBD@Z)
    logconsole.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall LogConsole::metaObject(void)const " (?metaObject@LogConsole@@UBEPBUQMetaObject@@XZ)
    ..\..\..\..\exe\logconsole.dll : fatal error LNK1120: 4 unresolved externals

    Build log was saved at "file://d:\Cvs_data\trash\BuildLog.htm"
    logconsole - 5 error(s), 5 warning(s)


    ---------------------- Done ----------------------

    Build: 0 succeeded, 1 failed, 0 skipped

    I have no idea where to start looking for a solution. Tried the form here... saw stuff about linking towards qtmain.lib QtCore4.lib instead of the qtmaind.lib QtCore4d.lib but this didnt have any effect.

    its qt 4.1.3 wit vs2003.

    The form that uses slots/signals needs to have the Q_OBJECT, the other form doesnt. Removing the Q_OBJECT on the form that doesnt need the slots/signals results in an dll that does in fact link. But where is the problem ????

    Any ideas ?
    Last edited by jacek; 31st July 2006 at 16:45. Reason: change [ code ] to [ quote ] to allow wrapping

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: problems with linking.... ??

    The problem is you didn't link with the moc-generated code for that class.

  3. The following user says thank you to wysota for this useful post:

    WinchellChung (28th August 2007)

  4. #3

    Thumbs up Re: problems with linking.... ??

    YESSS !!!

    muchos grazias...
    Thought that was done by the compiler automatically cause of the moc'ing and Uic'ing of the header files and ui files.

    But ok... Thanks !!!!

  5. #4
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problems with linking.... ??

    Hi can you explain to me what I have to do to moc and uic the files?
    I'm a newbie.
    Regards,
    Franco
    Franco Amato

Similar Threads

  1. static & dynamic linking
    By mickey in forum General Programming
    Replies: 6
    Last Post: 11th June 2010, 08:57
  2. QT4 Plugins - problems, problems
    By NormanDunbar in forum Qt Programming
    Replies: 6
    Last Post: 9th May 2006, 15:39
  3. I got two problems when I used static compiled library of QT4
    By qintm in forum Installation and Deployment
    Replies: 8
    Last Post: 20th April 2006, 08:52
  4. Replies: 4
    Last Post: 20th February 2006, 09:11
  5. Replies: 3
    Last Post: 30th January 2006, 15:13

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.