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 :
- set TEMPLATE variable of your .pro file to "lib" ( TEMPLATE = lib )
- add "dll" to the CONFIG variable ( CONFIG += dll )
- 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)
- declare all the functions, classes, variables to export as "symbols"
- compile it and link an app to it...
Sample code for 3)
#include <QtCore>
#ifdef _DLL_BUILD_
#define DLL_API Q_DECL_EXPORT
#else
#define DLL_API Q_DECL_IMPORT
#endif
#include <QtCore>
#ifdef _DLL_BUILD_
#define DLL_API Q_DECL_EXPORT
#else
#define DLL_API Q_DECL_IMPORT
#endif
To copy to clipboard, switch view to plain text mode
sample code for 4)
void DLL_API someFunction();
class DLL_API SomeClass
{
// definition
}
void DLL_API someFunction();
class DLL_API SomeClass
{
// definition
}
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...
Bookmarks