[Qt-interest] Exporting function

J-P Nurmi jpnurmi at gmail.com
Thu Mar 4 21:26:11 CET 2010


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.

--
J-P Nurmi




More information about the Qt-interest-old mailing list