[Qt-interest] Exporting function

André Hänsel andre at webkr.de
Thu Mar 4 22:31:46 CET 2010


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

André





More information about the Qt-interest-old mailing list