PDA

View Full Version : inconsitent dll linkage, MetaObject: definition of dllimport static member not allowe



mut
26th September 2014, 05:07
Using MSVC2013, Qt 5.3.2: I have compiled succesfully a lib Mylib.lib, Mylib.dll. Im trying to link it with my MyApp. however while
compiling my MyApp(with MSVC2013) I'm failing with "inconsitent dll linkage, MetaObject: definition of dllimport static member not allowed"

My library has:

1) Mylibraryglobal.h

#if defined(FLAGLIB_EXPORT)
# define FLAGLIB_EXPORT Q_DECL_EXPORT
#else
# define FLAGLIB_EXPORT Q_DECL_IMPORT
#endif

2) pro file of the library:
TEMPLATE = lib

3) MyLibclass.cpp:

class FLAGLIB_EXPORT MyClass : public QObject
{

}

MyApp is accessing all the header files of MyLib and using MyLib classes.

what should be the content of my MyApp project file in order to properly link to the library?

Thanks;

Mut

wysota
10th October 2014, 02:09
I think your Mylibraryglobal.h does not make sense. If you don't define FLAGLIB_EXPORT in your pro file you will get an import macro, if you do define it, you will get a compiler error about trying to redefine an existing macro. The if statement should operate on a different macro than the one that is used for the export/import.

anda_skoa
10th October 2014, 10:49
right, an export header usually looks like this



#ifndef MYLIB_EXPORT_H
#define MYLIB_EXPORT_H

#include <qglobal.h>

#ifndef MYLIB_EXPORT
# if defined(MAKE_MYLIB)
/* We are building this library */
# define MYLIB_EXPORT Q_DECL_EXPORT
# else
/* We are using this library */
# define MYLIB_EXPORT Q_DECL_IMPORT
# endif
#endif


#endif // MYLIB_EXPORT_H


Cheers,
_