PDA

View Full Version : problems with linking.... ??



thejester
31st July 2006, 16:06
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 ?

wysota
31st July 2006, 16:33
The problem is you didn't link with the moc-generated code for that class.

thejester
1st August 2006, 07:25
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 !!!! :) :) :)

franco.amato
10th July 2009, 20:35
Hi can you explain to me what I have to do to moc and uic the files?
I'm a newbie.
Regards,
Franco