Results 1 to 2 of 2

Thread: Using dll's in QT

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

    Default Using dll's in QT

    hi guys

    can we implement custom dll's in QT??

  2. #2
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Using dll's in QT

    Quote Originally Posted by qtguy
    hi guys

    can we implement custom dll's in QT??
    Excuse me but what do you call a "custom dll" ?
    If you want to create a dll the only things you need are :
    1. set TEMPLATE variable of your .pro file to "lib" ( TEMPLATE = lib )
    2. add "dll" to the CONFIG variable ( CONFIG += dll )
    3. create an header file like the one under and include it in every heaer of your dll that shall be accessible by the user (the coder that want to link to your dll)
    4. declare all the functions, classes, variables to export as "symbols"
    5. compile it and link an app to it...

    Sample code for 3)
    Qt Code:
    1. #include <QtCore>
    2.  
    3. #ifdef _DLL_BUILD_
    4. #define DLL_API Q_DECL_EXPORT
    5. #else
    6. #define DLL_API Q_DECL_IMPORT
    7. #endif
    To copy to clipboard, switch view to plain text mode 

    sample code for 4)
    Qt Code:
    1. void DLL_API someFunction();
    2.  
    3. class DLL_API SomeClass
    4. {
    5. // definition
    6. }
    To copy to clipboard, switch view to plain text mode 

    Notes :
    • you can replace DLL_API by any name you like...
    • in the example I've given you have to add "_DLL_BUILD_" to the DEFINES variable of your project (only the dll, not the executables linked to it...)
    • the DLL_API stuff is rather useless if your dll is not meant to be portable. It is required on window$ only...
    Current Qt projects : QCodeEdit, RotiDeCode

  3. The following 2 users say thank you to fullmetalcoder for this useful post:

    annalog (7th August 2006), sgonepudi (29th June 2006)

Similar Threads

  1. making a portable binary on windows
    By patcito in forum Qt Programming
    Replies: 10
    Last Post: 29th May 2006, 09:02

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.