PDA

View Full Version : 'staticMetaObject' : definition of dllimport static data member not allowed



alex1
5th October 2011, 09:25
Hi all.
I am creating a DLL on Windows XP (i'm use 2005 Professional Edition) VC 2005 error:
After compilation , I get an error code from "Moc'ing imgdll.h ..."
Help understand what is going?

I have following files:
===================ImgDll_global.h================ ====
#ifndef IMGDLL_GLOBAL_H
#define IMGDLL_GLOBAL_H

#include <QtCore/qglobal.h>

#if defined(IMGDLL_LIBRARY)
# define IMGDLLSHARED_EXPORT Q_DECL_EXPORT
#else
# define IMGDLLSHARED_EXPORT Q_DECL_IMPORT
#endif

#endif // IMGDLL_GLOBAL_H
=========================imgdll.h================= =====
#ifndef IMGDLL_H
#define IMGDLL_H

#include <QGraphicsView>
#include "ImgDll_global.h"

class IMGDLLSHARED_EXPORT ImgDll : public QGraphicsView {
Q_OBJECT
public:
ImgDll(QGraphicsScene* pScene, QWidget* pwgt = 0);
~ImgDll();

public slots:
void f1(qreal value = 1.1);
void f2(qreal value = 1.1);
private:
qreal getCurr() const;
};
==========================imgdll.cpp============== =========
#include <QtCore/qmath.h>
#include "imgdll.h"

ImgDll::ImgDll(QGraphicsScene* pScene, QWidget* pwgt)
: QGraphicsView(pScene, pwgt){}
ImgDll::~ImgDll(){}
void ImgDll::f1(qreal value ){.....}
void ImgDll::f2(qreal value) {...}

After compilation Debug\BuildLog.htm contain following data:

Build Log
Rebuild started: Project: ImgDll, Configuration: Debug|Win32

Command Lines
Creating temporary file "d:\Data\Documents\Visual Studio 2005\Projects\ImgDll\Debug\BAT00000244525728.bat" with contents
[
@echo off

"C:\Qt\4.7.3\bin\moc.exe" "d:\Data\Documents\Visual Studio 2005\Projects\ImgDll\ImgDll\imgdll.h" -o ".\GeneratedFiles\Debug\moc_imgdll.cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_CORE_LIB -DQT_GUI_LIB -DIMGDLL_LIB -D_WINDLL "-I." "-I.\GeneratedFiles" "-IC:\Qt\4.7.3\include" "-I.\GeneratedFiles\Debug\." "-IC:\Qt\4.7.3\include\qtmain" "-IC:\Qt\4.7.3\include\QtCore" "-IC:\Qt\4.7.3\include\QtGui" "-I."



if errorlevel 1 goto VCReportError

goto VCEnd

:VCReportError

echo Project : error PRJ0019: A tool returned an error code from "Moc'ing imgdll.h..."

exit 1

:VCEnd
]
Creating command line """d:\Data\Documents\Visual Studio 2005\Projects\ImgDll\Debug\BAT00000244525728.bat"""
Creating temporary file "d:\Data\Documents\Visual Studio 2005\Projects\ImgDll\Debug\RSP00000344525728.rsp" with contents
[
/Od /I ".\GeneratedFiles" /I "C:\Qt\4.7.3\include" /I ".\GeneratedFiles\Debug" /I "C:\Qt\4.7.3\include\qtmain" /I "C:\Qt\4.7.3\include\QtCore" /I "C:\Qt\4.7.3\include\QtGui" /I ".\\" /D "UNICODE" /D "WIN32" /D "QT_LARGEFILE_SUPPORT" /D "QT_CORE_LIB" /D "QT_GUI_LIB" /D "IMGDLL_LIB" /D "_WINDLL" /FD /EHsc /MDd /Zc:wchar_t- /Fo"d:\Data\Documents\Visual Studio 2005\Projects\ImgDll\Debug\\" /Fd"d:\Data\Documents\Visual Studio 2005\Projects\ImgDll\Debug\vc80.pdb" /c /Zi /TP ".\imgdll.cpp"
]
Creating command line "cl.exe @"d:\Data\Documents\Visual Studio 2005\Projects\ImgDll\Debug\RSP00000344525728.rsp" /nologo /errorReport:prompt"
Creating temporary file "d:\Data\Documents\Visual Studio 2005\Projects\ImgDll\Debug\RSP00000444525728.rsp" with contents
[
/Od /I ".\GeneratedFiles" /I "C:\Qt\4.7.3\include" /I ".\GeneratedFiles\Debug" /I "C:\Qt\4.7.3\include\qtmain" /I "C:\Qt\4.7.3\include\QtCore" /I "C:\Qt\4.7.3\include\QtGui" /I ".\\" /D "UNICODE" /D "WIN32" /D "QT_LARGEFILE_SUPPORT" /D "QT_CORE_LIB" /D "QT_GUI_LIB" /D "IMGDLL_LIB" /D "_WINDLL" /FD /EHsc /MDd /Zc:wchar_t- /Fo"d:\Data\Documents\Visual Studio 2005\Projects\ImgDll\Debug\moc_imgdll1.obj" /Fd"d:\Data\Documents\Visual Studio 2005\Projects\ImgDll\Debug\vc80.pdb" /c /Zi /TP ".\GeneratedFiles\Debug\moc_imgdll.cpp"
]
Creating command line "cl.exe @"d:\Data\Documents\Visual Studio 2005\Projects\ImgDll\Debug\RSP00000444525728.rsp" /nologo /errorReport:prompt"

Output Window
Moc'ing imgdll.h...
Compiling...
imgdll.cpp
.\imgdll.cpp(9) : warning C4273: 'ImgDll::ImgDll' : inconsistent dll linkage
d:\data\documents\visual studio 2005\projects\imgdll\imgdll\imgdll.h(10) : see previous definition of '{ctor}'
.\imgdll.cpp(15) : warning C4273: 'ImgDll::~ImgDll' : inconsistent dll linkage
d:\data\documents\visual studio 2005\projects\imgdll\imgdll\imgdll.h(11) : see previous definition of '{dtor}'
.\imgdll.cpp(19) : warning C4273: 'ImgDll::slotZoomIn' : inconsistent dll linkage
d:\data\documents\visual studio 2005\projects\imgdll\imgdll\imgdll.h(14) : see previous definition of 'slotZoomIn'
.\imgdll.cpp(30) : warning C4273: 'ImgDll::slotZoomOut' : inconsistent dll linkage
d:\data\documents\visual studio 2005\projects\imgdll\imgdll\imgdll.h(15) : see previous definition of 'slotZoomOut'
.\imgdll.cpp(41) : warning C4273: 'ImgDll::slotRotateLeft' : inconsistent dll linkage
d:\data\documents\visual studio 2005\projects\imgdll\imgdll\imgdll.h(16) : see previous definition of 'slotRotateLeft'
.\imgdll.cpp(46) : warning C4273: 'ImgDll::slotRotateRight' : inconsistent dll linkage
d:\data\documents\visual studio 2005\projects\imgdll\imgdll\imgdll.h(17) : see previous definition of 'slotRotateRight'
.\imgdll.cpp(51) : warning C4273: 'ImgDll::slotRotateLeft90Degree' : inconsistent dll linkage
d:\data\documents\visual studio 2005\projects\imgdll\imgdll\imgdll.h(18) : see previous definition of 'slotRotateLeft90Degree'
.\imgdll.cpp(56) : warning C4273: 'ImgDll::slotRotateRight90Degree' : inconsistent dll linkage
d:\data\documents\visual studio 2005\projects\imgdll\imgdll\imgdll.h(19) : see previous definition of 'slotRotateRight90Degree'
.\imgdll.cpp(61) : warning C4273: 'ImgDll::slotFitToScreen' : inconsistent dll linkage
d:\data\documents\visual studio 2005\projects\imgdll\imgdll\imgdll.h(20) : see previous definition of 'slotFitToScreen'
.\imgdll.cpp(66) : warning C4273: 'ImgDll::slotOriginalScale' : inconsistent dll linkage
d:\data\documents\visual studio 2005\projects\imgdll\imgdll\imgdll.h(21) : see previous definition of 'slotOriginalScale'
.\imgdll.cpp(77) : warning C4273: 'ImgDll::getCurrentScale' : inconsistent dll linkage
d:\data\documents\visual studio 2005\projects\imgdll\imgdll\imgdll.h(24) : see previous definition of 'getCurrentScale'
Compiling...
moc_imgdll.cpp
.\GeneratedFiles\Debug\moc_imgdll.cpp(60) : warning C4273: 'staticMetaObject' : inconsistent dll linkage
d:\data\documents\visual studio 2005\projects\imgdll\imgdll\generatedfiles\debug\. ./../imgdll.h(8) : see previous definition of 'public: static QMetaObject const ImgDll::staticMetaObject'
.\GeneratedFiles\Debug\moc_imgdll.cpp(60) : error C2491: 'ImgDll::staticMetaObject' : definition of dllimport static data member not allowed
.\GeneratedFiles\Debug\moc_imgdll.cpp(70) : warning C4273: 'ImgDll::metaObject' : inconsistent dll linkage
d:\data\documents\visual studio 2005\projects\imgdll\imgdll\generatedfiles\debug\. ./../imgdll.h(8) : see previous definition of 'metaObject'
.\GeneratedFiles\Debug\moc_imgdll.cpp(75) : warning C4273: 'ImgDll::qt_metacast' : inconsistent dll linkage
d:\data\documents\visual studio 2005\projects\imgdll\imgdll\generatedfiles\debug\. ./../imgdll.h(8) : see previous definition of 'qt_metacast'
.\GeneratedFiles\Debug\moc_imgdll.cpp(83) : warning C4273: 'ImgDll::qt_metacall' : inconsistent dll linkage
d:\data\documents\visual studio 2005\projects\imgdll\imgdll\generatedfiles\debug\. ./../imgdll.h(8)
Results
Build log was saved at "file://d:\Data\Documents\Visual Studio 2005\Projects\ImgDll\Debug\BuildLog.htm"
ImgDll - 1 error(s), 15 warning(s)

thanks in advance!!!

fullmetalcoder
19th October 2011, 21:34
What about adding IMGDLL_LIBRARY to the project defines?

d_stranz
20th October 2011, 15:14
What about adding IMGDLL_LIBRARY to the project defines?

Yes, you have defined "IMGDLL_LIB", not "IMGDLL_LIBRARY" as your code requires. Look carefully at the content of the first command line in your output listing.

Edit: Just noticed the OP was over two weeks ago. I hope you've figured this out by now. :)