Results 1 to 3 of 3

Thread: 'staticMetaObject' : definition of dllimport static data member not allowed

  1. #1
    Join Date
    Aug 2011
    Posts
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question 'staticMetaObject' : definition of dllimport static data member not allowed

    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 /errorReportrompt"
    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 /errorReportrompt"

    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!!!

  2. #2
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: 'staticMetaObject' : definition of dllimport static data member not allowed

    What about adding IMGDLL_LIBRARY to the project defines?
    Current Qt projects : QCodeEdit, RotiDeCode

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: 'staticMetaObject' : definition of dllimport static data member not allowed

    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.

Similar Threads

  1. Using a static member in a class
    By feraudyh in forum Newbie
    Replies: 4
    Last Post: 29th April 2010, 11:58
  2. static member function
    By freekill in forum Newbie
    Replies: 4
    Last Post: 29th July 2009, 16:23
  3. Replies: 22
    Last Post: 8th October 2008, 14:54
  4. Replies: 3
    Last Post: 19th February 2008, 14:10
  5. static member initialization
    By high_flyer in forum General Programming
    Replies: 2
    Last Post: 17th September 2007, 22:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.