PDA

View Full Version : Problems using DLL



larsli
12th July 2006, 14:28
I'm trying to use a DLL which consists of one UI which I have subclassed. (I'm using Qt3 and Visual Studio .NET 2003) The UI is called MyMainWindowBase.ui which results in MyMainWindowBase.h and MyMainWindowBase.cpp when uic'ed. Then I subclass this in my own class called MyMainWindow. MyMainWindow includes my own DLL_EXPORT macro. But when I create a DLL and try to link this with some other code I get a lot of unresolved externals from MyMainWindowBase. I guess this is because the symbols in that class are not exported, because if I remove the DLL_EXPORT macro from MyMainWindow I get a lot of unresolved externals from that too. How can I get the symbols from the base class exported, or is there something else I'm missing?

Myinterface.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall MyMainWindowBase::languageChange(void)" (?languageChange@MyMainWindowBase@@MAEXXZ)
Myinterface.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall MyMainWindowBase::~MyMainWindowBase(void)" (??1MyMainWindowBase@@UAE@XZ) referenced in function $L32824
Myinterface.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall MyMainWindowBase::qt_property(int,int,class QVariant *)" (?qt_property@MyMainWindowBase@@UAE_NHHPAVQVariant @@@Z)
Myinterface.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall MyMainWindowBase::qt_emit(int,struct QUObject *)" (?qt_emit@MyMainWindowBase@@UAE_NHPAUQUObject@@@Z)
Myinterface.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall MyMainWindowBase::qt_invoke(int,struct QUObject *)" (?qt_invoke@MyMainWindowBase@@UAE_NHPAUQUObject@@@ Z)
Myinterface.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall MyMainWindowBase::qt_cast(char const *)" (?qt_cast@MyMainWindowBase@@UAEPAXPBD@Z)
Myinterface.obj : error LNK2001: unresolved external symbol "public: virtual char const * __thiscall MyMainWindowBase::className(void)const " (?className@MyMainWindowBase@@UBEPBDXZ)
Myinterface.obj : error LNK2019: unresolved external symbol "public: static class QMetaObject * __cdecl MyMainWindowBase::staticMetaObject(void)" (?staticMetaObject@MyMainWindowBase@@SAPAVQMetaObj ect@@XZ) referenced in function "public: virtual class QMetaObject * __thiscall MyMainWindowBase::metaObject(void)const " (?metaObject@MyMainWindowBase@@UBEPAVQMetaObject@@ XZ)
..\lib\debug\win32\Mymainwindow.dll : fatal error LNK1120: 8 unresolved externals

Chicken Blood Machine
12th July 2006, 16:58
You didn't moc the header file.

larsli
13th July 2006, 09:32
Thanks for the answer, but the header file is moc'ed. It's in the Generated MOC files in the Visual Studio solution explorer tree.

high_flyer
13th July 2006, 12:49
Did I get it right - that you have a ui generated class and a subclass of that ui class in your dll?
If so, you need to export the ui generated class methods that are offered via the dll.
Since the ui generated class in the dll is not goig to be changed by uic again,you can just add the export macros to it - provided I understood correctly what you did.

Chicken Blood Machine
13th July 2006, 16:36
Thanks for the answer, but the header file is moc'ed. It's in the Generated MOC files in the Visual Studio solution explorer tree.

In Designer, ensure that the export macro is added to your generated base class, by putting it in the 'macros' section of the object viewer tree (I can't remember right now, but it's either called 'macros' or 'defines')

gfunk
13th July 2006, 18:59
Maybe you can just add the DLL_EXPORT macro to the base class?

Chicken Blood Machine
13th July 2006, 19:07
Maybe you can just add the DLL_EXPORT macro to the base class?

He can, but then it will disappear whenever he changes his ui.

gfunk
13th July 2006, 19:16
Oh, you're right, haha.

I can't find the object viewer tree, is this part of the object inspector?

Chicken Blood Machine
13th July 2006, 21:38
Oh, you're right, haha.

I can't find the object viewer tree, is this part of the object inspector?

Yes, sorry Object Inspector. I don't have a copy of Qt3 Designer to hand.

gfunk
13th July 2006, 21:49
Where is the macros or defines section in Object Inspector? Or is this just in Qt3? And if yes, is there a Qt4 equivalent? (I'm using Qt4, Windows version, myself)

Thanks,

Chicken Blood Machine
13th July 2006, 21:53
Thre's nothing in Qt4 (and you don't need it). There is no generated baseclass as such in Qt4*

* You can subclass the ui class in Qt4, but none of the symbols need to be eported.

larsli
15th July 2006, 10:18
Thanks for all the answers. There is a export macro property in Qt3 Designer. It's a sub property of the name property. Well hidden! :)