Results 1 to 3 of 3

Thread: Linker Error

  1. #1
    Join Date
    Mar 2006
    Location
    Vadodara, Gujarat, India
    Posts
    65
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy dll problem

    Hi Guys,
    i m here again for ur help ...

    i've prepared a dll, that provides a table in the main program and the excel like operations (cut,copy,paste ....)

    my dll is compiling working fine, but when i use that dll warnings and error come.

    please look at the following compiler error :

    Qt Code:
    1. Compiling...
    2. moc_QGrid.cpp
    3. warning C4273: 'public: static struct QMetaObject const QGrid::staticMetaObject' : inconsistent dll linkage. dllexport assumed.
    4. error C2491: 'QGrid::staticMetaObject' : definition of dllimport static data member not allowed
    5. warning C4273: 'metaObject' : inconsistent dll linkage. dllexport assumed.
    6. warning C4273: 'qt_metacast' : inconsistent dll linkage. dllexport assumed.
    7. warning C4273: 'qt_metacall' : inconsistent dll linkage. dllexport assumed.
    8. Error executing cl.exe.
    9.  
    10. program.exe - 1 error(s), 4 warning(s)
    To copy to clipboard, switch view to plain text mode 

    my pro file for the main project:

    Qt Code:
    1. ######################################################################
    2. # Automatically generated by qmake (2.00a) Mon Jan 2 11:42:05 2006
    3. ######################################################################
    4.  
    5. TEMPLATE = app
    6. TARGET += program
    7. DEPENDPATH += . ui Uidata
    8. INCLUDEPATH += . ../header/
    9.  
    10. # Input
    11. HEADERS += xxx.h yyy.h
    12. FORMS += Uidata/xxx.cpp Uidata/yyy.cpp
    13. SOURCES += xxx.cpp yyy.cpp
    14. RESOURCES += Uidata/tds.qrc
    15. QT += xml
    16. UI_DIR = ui
    17. MOC_DIR = moc
    18. OBJECTS_DIR = obj
    19. LIBS = ../dll/release/QGrid.lib
    To copy to clipboard, switch view to plain text mode 

    my QGrid.h file is something like this :
    Qt Code:
    1. #ifndef QGRID_H
    2. #define QGRID_H
    3. #include <QtCore/qglobal.h>
    4. #include <QTableWidget>
    5.  
    6.  
    7. #ifdef Q_OS_WIN
    8. # ifdef BUILD_QGRID
    9. # define QGRID_EXPORT Q_DECL_EXPORT
    10. # else
    11. # define QGRID_EXPORT Q_DECL_IMPORT
    12. # endif
    13. #else
    14. # define QGRID_EXPORT
    15. #endif
    16.  
    17. #include <QAction>
    18.  
    19. class QGRID_EXPORT QGrid : public QTableWidget
    20. {
    21. Q_OBJECT
    22. public:
    23. QGrid(int c,int r,QWidget *parent = 0);
    24. QGrid(QWidget *parent = 0);
    25.  
    26. private:
    27. QAction *cutAct;
    28. QAction *copyAct;
    29. QAction *pasteAct;
    30.  
    31. public slots:
    32. void cut();
    33. void copy();
    34. void paste();
    35. public:
    36. void setUpContextMenu();
    37. void createActions();
    38. };
    39. #endif
    To copy to clipboard, switch view to plain text mode 

    i m not getting the cause of the error. i generated the preprocessor files to chk if some problem in macro expansion, but it expands fine .... in dll it expands to __declspec(dllexport) and in the main project it expands to __declspec(dllimport)

    when i keep the .cpp and .h file in the main project, this error won't come.

    i m using MSVC++ for sompiling the project.

    Please help guys, i m stuk for last 1 week in this ...
    Do what u r afraid to do, and the death of fear is sure.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Linker Error

    It looks like moc is run on your library headers.

  3. #3
    Join Date
    Mar 2006
    Location
    Vadodara, Gujarat, India
    Posts
    65
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Talking Re: Compiler's Error (not Linker)

    hi,
    thanx 4 replying. the problem is solved, the errors are gone, but i don't know y & how ..
    i followed the method prescribed by ChristianEhrlicher posted in my other thread, and did like this :

    Qt Code:
    1. #ifdef BUILD_QGRID
    2. # ifdef Q_CC_MSVC
    3. # define QGRID_EXPORT Q_DECL_EXPORT
    4. # else
    5. # define QGRID_EXPORT Q_DECL_IMPORT
    6. # endif
    7. #else
    8. # define QGRID_EXPORT
    9. #endif
    To copy to clipboard, switch view to plain text mode 

    this way it compiles error free.
    i earlier used the code (below) :

    Qt Code:
    1. #ifdef Q_OS_WIN32
    2. # ifdef BUILD_QGRID
    3. # define QGRID_EXPORT Q_DECL_EXPORT
    4. # else
    5. # define QGRID_EXPORT Q_DECL_IMPORT
    6. # endif
    7. #else
    8. # define QGRID_EXPORT
    9. #endif
    To copy to clipboard, switch view to plain text mode 

    is there much difference in these codes ? as per logic, both must work fine ....
    and ya the error was compiler error not the linker's, but now i can't edit the topic

    thanx
    Do what u r afraid to do, and the death of fear is sure.

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  2. Compile 4.4.0
    By LordQt in forum Installation and Deployment
    Replies: 18
    Last Post: 29th May 2008, 13:43
  3. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  4. Error compiling psql plugin
    By vieraci in forum Installation and Deployment
    Replies: 4
    Last Post: 7th October 2007, 02:49
  5. qt 4.2.2 install on aix
    By try to remember in forum Installation and Deployment
    Replies: 2
    Last Post: 28th March 2007, 12:19

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.