- Create a qmake project, specifying "TEMPLATE = lib" and maybe "CONFIG += shared"
- Add an header which will hold some crucial macros, ideally it should be called $projectname$.h
- In this file add the following code (some names may be changed...)
#ifdef _PROJECT_BUILD_
#if (defined(QT_SHARED) || defined(QT_DLL)) && !defined(QT_PLUGIN)
#define PROJECT_EXPORT Q_DECL_EXPORT
#else
#define PROJECT_EXPORT
#endif
#else
#define PROJECT_EXPORT Q_DECL_IMPORT
#endif
#ifdef _PROJECT_BUILD_
#if (defined(QT_SHARED) || defined(QT_DLL)) && !defined(QT_PLUGIN)
#define PROJECT_EXPORT Q_DECL_EXPORT
#else
#define PROJECT_EXPORT
#endif
#else
#define PROJECT_EXPORT Q_DECL_IMPORT
#endif
To copy to clipboard, switch view to plain text mode
Then include this file in all headers containing classes definition meant to be exported and place this macro between the "class" keyword and your class name.
Compile your dll.
To link the created dll through qmake add the following line to your project file :
LIBS += -L$path/to/your/dll$ -l$name_of_your_dll_without_suffix$
And you're done!!!
Bookmarks