Results 1 to 12 of 12

Thread: Problems using DLL

  1. #1
    Join Date
    Mar 2006
    Posts
    8
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Problems using DLL

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problems using DLL

    You didn't moc the header file.
    Save yourself some pain. Learn C++ before learning Qt.

  3. #3
    Join Date
    Mar 2006
    Posts
    8
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problems using DLL

    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Problems using DLL

    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.

  5. #5
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problems using DLL

    Quote Originally Posted by larsli
    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')
    Save yourself some pain. Learn C++ before learning Qt.

  6. #6
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Problems using DLL

    Maybe you can just add the DLL_EXPORT macro to the base class?
    Software Engineer



  7. #7
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problems using DLL

    Quote Originally Posted by gfunk
    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.
    Save yourself some pain. Learn C++ before learning Qt.

  8. #8
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Problems using DLL

    Oh, you're right, haha.

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



  9. #9
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problems using DLL

    Quote Originally Posted by gfunk
    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.
    Save yourself some pain. Learn C++ before learning Qt.

  10. #10
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Problems using DLL

    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,
    Software Engineer



  11. #11
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problems using DLL

    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.
    Save yourself some pain. Learn C++ before learning Qt.

  12. The following user says thank you to Chicken Blood Machine for this useful post:

    gfunk (13th July 2006)

  13. #12
    Join Date
    Mar 2006
    Posts
    8
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problems using DLL

    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!

Similar Threads

  1. Problems building mysql plugin for Qt 4.1.2 on windows XP
    By Philip_Anselmo in forum Installation and Deployment
    Replies: 3
    Last Post: 17th May 2006, 15:38
  2. Canvas problems
    By Tommytrojan in forum Qt Programming
    Replies: 22
    Last Post: 9th May 2006, 16:46
  3. QT4 Plugins - problems, problems
    By NormanDunbar in forum Qt Programming
    Replies: 6
    Last Post: 9th May 2006, 15:39
  4. [Win32/VC++ 8.0] Strange problems with qrc_*.cpp files
    By mloskot in forum Installation and Deployment
    Replies: 6
    Last Post: 6th March 2006, 10:28
  5. problems with Opengl
    By SlawQ in forum Qt Programming
    Replies: 4
    Last Post: 12th February 2006, 22:49

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.