[Qt-interest] Exporting function

Eric Clark eclark at ara.com
Thu Mar 4 23:07:42 CET 2010



> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> bounces at trolltech.com] On Behalf Of André Hänsel
> Sent: Thursday, March 04, 2010 3:32 PM
> To: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] Exporting function
> 
> Eric Clark wrote:
> 
> > This is the actual code behind Q_DECL_EXPORT and Q_DECL_IMPORT:
> >
> > #ifdef BUILD_MY_LIB
> > #define MY_EXPORT __declspec(dllexport)
> > #else
> > #define MY_EXPORT __declspec(dllimport)
> > #endif
> >
> > And, yes, that is 2 (two) underscores in front of declspec! The
> define,
> > BUILD_MY_LIB, can only be defined in the lib that is exporting the
> > functions. Any lib that tries to use your lib, CANNOT have
> BUILD_MY_LIB
> > defined.
> >
> 
> No matter how you call it, MY_EXPORT, Q_DECL_EXPORT or
> __declspec(dllexport), it produces the same error (sure, it's the
> same!):
> 
> extern "C" HRESULT COMSHARED_EXPORT __stdcall
> DllGetClassObject(REFCLSID
> objGuid, REFIID factoryGuid, LPVOID *factoryHandle)
> -> Redefinition; different linkage
> 
> extern "C" HRESULT Q_DECL_EXPORT __stdcall DllGetClassObject(REFCLSID
> objGuid, REFIID factoryGuid, LPVOID *factoryHandle)
> -> Redefinition; different linkage
> 
> extern "C" HRESULT __declspec(dllexport) __stdcall
> DllGetClassObject(REFCLSID objGuid, REFIID factoryGuid, LPVOID
> *factoryHandle)
> -> Redefinition; different linkage

This error usually means that the function is being exported in multiple places. In other words, the function that is trying to call this function exists in a separate lib, but has it defined as dllexport and not dllimport. For this fix, you will need to track down where you are defining "COM_LIBRARY" and make sure it is not defined in the calling library.

The other reason for this error would be that you have COMSHARED_EXPORT/COMSHARED_IMPORT defined in multiple places. 

Eric

> 
> André
> 
> 
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list