Results 1 to 3 of 3

Thread: DLL problem im confuse..

  1. #1
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default DLL problem im confuse..



    first can you guys check if what i did is right?

    in my .h

    Qt Code:
    1. #ifdef MYDLL
    2. #define MYDLLAPI Q_DECL_EXPORT
    3. #else
    4. #define MYDLLAPI
    5. #endif
    6.  
    7. #include <QDialog>
    8.  
    9. class MYDLLAPI MyClass : public QDialog
    10. {
    11. Q_OBJECT
    12. public:
    13. MyClass(QWidget * parent = 0, Qt::WFlags f = 0 );
    14. public slots:
    15. void showMsg();
    16. }
    17.  
    18. /*i dont have a UI*/
    To copy to clipboard, switch view to plain text mode 

    in my .pro
    Qt Code:
    1. /*i added*/
    2. CONFIG += dll release
    3. TEMPLATE = lib
    4. DEFINES = MYDLL
    To copy to clipboard, switch view to plain text mode 

    this will create a myclass.a and myclass.dll (im using windows mingw)

    it will be use by the other application
    here's what I've done

    in my app .pro i added
    Qt Code:
    1. LIBS += "<path to my lib>\libmyclass.a"
    2. INCLUDEPATH = "<path to includes>"
    To copy to clipboard, switch view to plain text mode 

    in my app code
    Qt Code:
    1. #include "myclass.h" //from the include of dll
    2.  
    3. /*some includes*/
    4.  
    5. int main (int argc, char * argv [])
    6. {
    7. QApplication app( argc, argv );
    8. QLibrary *loadmylibrary = new QLibrary("myclass"); //my dll
    9. loadmylibrary->setLoadHints(QLibrary::ResolveAllSymbolsHint);
    10. loadmylibrary->load();
    11. if (loadmylibrary->isLoaded() == false)
    12. qDebug()<<"error not loaded";
    13.  
    14. else
    15. {
    16. qDebug()<<"loaded";
    17. MyClass *mycls; //from my dll
    18.  
    19. mycls->showMsg();
    20. }
    21.  
    22. app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
    23. return app.exec();
    24. }
    To copy to clipboard, switch view to plain text mode 

    my applications show:
    loaded

    QWidget: Must construct a QApplication before a QPaintDevice
    then the messagebox will not show from the dll.. how can i solve this?

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: DLL problem im confuse..

    Why are you linking to and loading the same library again at runtime?
    J-P Nurmi

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

    triperzonak (26th February 2009)

  4. #3
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: DLL problem im confuse..

    thanks bro..

    i remove the QLibrary and rebuild my apps and dll.. it is now working.

    is there a problem if i build a dll from static build of qt?..
    Last edited by triperzonak; 26th February 2009 at 02:20.

Similar Threads

  1. Very strange socket programming problem
    By montylee in forum Qt Programming
    Replies: 5
    Last Post: 11th November 2008, 12:05
  2. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  3. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  4. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 10:35
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.