
Originally Posted by
wysota
the __declspec() stuff is not portable... If you use Qt you should rely on the convinience macros : Q_DECL_EXPORT and Q_DECL_IMPORT instead. The first one has to be set when building a dll and the second one when linking to a dll. They can be managed either by an include file common to all the files of the dll, typically looking like this :
#ifdef _X_BUILD_
#if (defined(QT_DLL) || defined(QT_SHARED)) && !defined(QT_PLUGIN)
// lib being compiled shared
#define X_EXPORT Q_DECL_EXPORT
#else
// lib being embedded
#define X_EXPORT
#else
// lib being linked against (must be shared on Window$!)
#define X_EXPORT Q_DECL_IMPORT
#endif
#ifdef _X_BUILD_
#if (defined(QT_DLL) || defined(QT_SHARED)) && !defined(QT_PLUGIN)
// lib being compiled shared
#define X_EXPORT Q_DECL_EXPORT
#else
// lib being embedded
#define X_EXPORT
#else
// lib being linked against (must be shared on Window$!)
#define X_EXPORT Q_DECL_IMPORT
#endif
To copy to clipboard, switch view to plain text mode
or inside the projects through the DEFINES variable. In the dll project
DEFINES += -DX_EXPORT=Q_DECL_EXPORT
DEFINES += -DX_EXPORT=Q_DECL_EXPORT
To copy to clipboard, switch view to plain text mode
and in the client project :
DEFINES += -DX_EXPORT=Q_DECL_IMPORT
DEFINES += -DX_EXPORT=Q_DECL_IMPORT
To copy to clipboard, switch view to plain text mode
Then all classes/function/variables meant to be exported (accessible when linking against the lib) have to be prefixed with X_EXPORT (or whatever the name choosen
). For instance :
X_EXPORT void someFunction();
class X_EXPORT someClass
{
public:
someClass();
}
X_EXPORT void someFunction();
class X_EXPORT someClass
{
public:
someClass();
}
To copy to clipboard, switch view to plain text mode
Hope this helps.
Bookmarks