[Qt-interest] Exporting function
André Hänsel
andre at webkr.de
Thu Mar 4 21:33:57 CET 2010
J-P Nurmi wrote:
> On Thu, Mar 4, 2010 at 10:18 PM, André Hänsel <andre at webkr.de> wrote:
> > Hi list,
> >
> > what is the correct way to export a function using Qt and MSVC?
> >
> > With
> >
> > extern "C" HRESULT Q_DECL_EXPORT __stdcall DllGetClassObject(REFCLSID
> > objGuid, REFIID factoryGuid, LPVOID *factoryHandle)
> >
> > I get an "Redefinition; different linkage" error.
> >
> > Regards,
> > André
> >
>
> Hi,
>
> You export when building the lib and import when using the lib.
>
> .pro:
> DEFINES += BUILD_MY_LIB
>
> .h
> #ifdef BUILD_MY_LIB
> #define MY_EXPORT Q_DECL_EXPORT
> #else
> #define MY_EXPORT Q_DECL_IMPORT
> #endif
>
> And then use MY_EXPORT instead of Q_DECL_EXPORT/IMPORT directly.
Yes, of course, I have:
#if defined(COM_LIBRARY)
# define COMSHARED_EXPORT Q_DECL_EXPORT
#else
# define COMSHARED_EXPORT Q_DECL_IMPORT
#endif
But because of the define this is the same:
extern "C" HRESULT COMSHARED_EXPORT __stdcall DllGetClassObject(REFCLSID
objGuid, REFIID factoryGuid, LPVOID *factoryHandle)
and so gives the same error.
André
More information about the Qt-interest-old
mailing list