Results 1 to 4 of 4

Thread: Why do I still get LNK 2001 error when I have defined the QWT_DLL preprocessor???

  1. #1
    Join Date
    Nov 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Why do I still get LNK 2001 error when I have defined the QWT_DLL preprocessor??

    I defined a class inherited from QDialog, the class has a QwtPlot, when I compile the project, LNK 2001 error occured:

    griddatadialog.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall GridDataDialog::metaObject(void)const " (?metaObject@GridDataDialog@@UBEPBUQMetaObject@@XZ )
    1>griddatadialog.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall GridDataDialog::qt_metacast(char const *)" (?qt_metacast@GridDataDialog@@UAEPAXPBD@Z)
    1>griddatadialog.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall GridDataDialog::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@GridDataDialog@@UAEHW4Call@QMetaObje ct@@HPAPAX@Z)
    1>griddatadialog.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const GridDataDialog::staticMetaObject" (?staticMetaObject@GridDataDialog@@2UQMetaObject@@ B)


    if I comment out the Q_OBJECT macro, no link error occured, but I can't use the buttons and combobox in the dialog, I've defined the QWT_DLL preprocessor, does anyone know how to solve this problem??Thanks a lot.


    Added after 5 minutes:


    Forget to say, I use Visual Studio 2005, and compile both the QWT source code and my own project in debug mode. How does the error occur???
    Last edited by accordionist; 15th November 2010 at 00:45.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Why do I still get LNK 2001 error when I have defined the QWT_DLL preprocessor??

    Are the qwt libraries in the LIBS variable of your PRO file? For example:
    Qt Code:
    1. QWTPATH = C:/Qwt-5.2.1
    2. INCLUDEPATH += $$QWTPATH/include
    3. LIBS += -L$$QWTPATH/lib -lqwt5
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Nov 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Why do I still get LNK 2001 error when I have defined the QWT_DLL preprocessor??

    I' ve solved the problem myself!! My Visual Studio doesn't generate the moc_XXX.cpp file automatically. Open Visual Studio, right click the .h file, select properties, Custom Build Step, Command Line Step, input "%qtdir%\bin\moc.exe" "$(InputDir)$(InputName).h" -o "ui\moc_$(InputName).cpp", then build the project, and then add the generated moc_XXX.cpp file to the project, the errors disappear!

  4. #4
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Why do I still get LNK 2001 error when I have defined the QWT_DLL preprocessor??

    If you have the VisualStudio Qt-AddIn installed, you can create a Qt-Project instead of a console-application. Then these generating-steps will be performed automatically

Similar Threads

  1. A question on preprocessor
    By Dante in forum Qt Programming
    Replies: 1
    Last Post: 9th July 2009, 22:28
  2. Error::defined after prior declaration as dllimport:
    By hasnatzaidi in forum Qt Programming
    Replies: 2
    Last Post: 12th June 2009, 01:37
  3. Signal and "already defined" error
    By QPlace in forum Qt Programming
    Replies: 3
    Last Post: 4th June 2009, 02:06
  4. Qt4 Preprocessor defines
    By Chicken Blood Machine in forum Qt Programming
    Replies: 12
    Last Post: 23rd March 2006, 16:28
  5. QT & VC++ 8 preprocessor setting
    By Ngoc in forum Qt Programming
    Replies: 0
    Last Post: 3rd March 2006, 20:40

Tags for this Thread

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.