Results 1 to 3 of 3

Thread: error LNK2019: unresolved external symbol

  1. #1
    Join Date
    Feb 2013
    Posts
    28
    Thanks
    13
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default error LNK2019: unresolved external symbol

    I’ve been through 20 subject about this error, but I didn’t figure how to fix it
    -I’m using Qt 5.0.1, Qtcreatro 2.6.2 – with visual studio 2010 on windows 7 64bit
    Here is my code
    the .pro file
    Qt Code:
    1. #-------------------------------------------------
    2. #
    3. # Project created by QtCreator 2013-02-02T23:22:32
    4. #
    5. #-------------------------------------------------
    6.  
    7. QT += core gui
    8.  
    9. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    10.  
    11. TARGET = first
    12. TEMPLATE = app
    13. SOURCES += main.cpp\
    14. mycalculator.cpp \
    15. display.cpp
    16.  
    17. HEADERS += mycalculator.h \
    18. display.h
    19.  
    20. OTHER_FILES += \
    21. Comments.txt
    To copy to clipboard, switch view to plain text mode 

    The .h file
    Qt Code:
    1. #ifndef MYCALCULATOR_H
    2. #define MYCALCULATOR_H
    3. #include <QPushButton>
    4. #include <QTextEdit>
    5. #include "display.h"
    6. class MyCalculator : public QWidget
    7. {
    8. Q_OBJECT
    9. public:
    10. MyCalculator(QWidget *parent = 0);
    11. //QSize sizeHint() const;
    12. private:
    13. Display *mydisplay;
    14. enum{digitArrayIndex = 10};
    15. QPushButton *digitButtons[digitArrayIndex];
    16. QPushButton *addButton,*subButton,*mulButton,*divButton;
    17. //there is 6 functions for now
    18. QPushButton *sinButton,*cosButton,*tanButton;
    19. QPushButton *powerButton,*sqrtButton,*lnButton;
    20. QPushButton *equalButton,*pointButton,*clearButton,*delButton,*ansButton;
    21. private slots:
    22. void digitClicked();
    23. void operationClicked();
    24. void functionClicked();
    25. void equalClicked();
    26. void pointClicked();
    27. void clearClicked();
    28. void delClicked();
    29. void ansClicked();
    30. private: //functions
    31. QPushButton *createButton(const QString &text, const char *buttonSlot);
    32. };
    33. #endif // MYCALCULATOR_H
    To copy to clipboard, switch view to plain text mode 

    The .cpp file
    Qt Code:
    1. #include <QGridLayout>
    2. #include <QScrollArea>
    3. #include "mycalculator.h"
    4. #include "display.h"
    5. MyCalculator::MyCalculator(QWidget *parent)
    6. : QWidget(parent)
    7. {
    8. QGridLayout *myBasicGrid = new QGridLayout(this);
    9. myBasicGrid->setSizeConstraint(QLayout::SetFixedSize);
    10. mydisplay = new Display;
    11. //display->setReadOnly(true);
    12. /*QFont displayFont = display->font();
    13.   displayFont.setPointSize(displayFont.pointSize() + 4);
    14.   display->setFont(displayFont);*/
    15. //Implement operation buttons
    16. addButton = createButton("+",SLOT(operationClicked()));
    17. subButton = createButton("-",SLOT(operationClicked()));
    18. mulButton = createButton("\303\227",SLOT(operationClicked()));
    19. divButton = createButton("\303\267",SLOT(operationClicked()));
    20. //Implement function buttons
    21. sinButton = createButton("sin",SLOT(functionClicked()));
    22. cosButton = createButton("cos",SLOT(functionClicked()));
    23. tanButton = createButton("tan",SLOT(functionClicked()));
    24. powerButton = createButton("x\302\262",SLOT(functionClicked()));
    25. sqrtButton = createButton("\342\210\232",SLOT(functionClicked()));
    26. lnButton = createButton("ln",SLOT(functionClicked()));
    27. //The rest of the buttons
    28. equalButton = createButton("=",SLOT(equalClicked()));
    29. pointButton = createButton(".",SLOT(pointClicked()));
    30. ansButton = createButton("Ans",SLOT(ansClicked()));
    31. delButton = createButton("DEL",SLOT(delClicked()));
    32. clearButton = createButton("AC",SLOT(clearClicked()));
    33. //The digit buttons
    34. digitButtons[0] = createButton("0",SLOT(digitClicked()));
    35. for(int i = 1; i<digitArrayIndex; i++){
    36. digitButtons[i] = createButton(QString::number(i),SLOT(digitClicked()));
    37. int row = ((9 - i) / 3) + 2;
    38. int column = ((i - 1) % 3);
    39. myBasicGrid->addWidget(digitButtons[i],row,column); //Adding the digit buttons to the grid
    40. }
    41.  
    42. //layout the display and the rest of the buttons
    43. //myBasicGrid->addWidget(mydisplay,0,0,1,5);
    44. myBasicGrid->addWidget(digitButtons[0],5,0);
    45. myBasicGrid->addWidget(sinButton,1,0);
    46. myBasicGrid->addWidget(cosButton,1,1);
    47. myBasicGrid->addWidget(tanButton,1,2);
    48. myBasicGrid->addWidget(powerButton,1,3);
    49. myBasicGrid->addWidget(sqrtButton,1,4);
    50. myBasicGrid->addWidget(delButton,2,3);
    51. myBasicGrid->addWidget(clearButton,2,4);
    52. myBasicGrid->addWidget(mulButton,3,3);
    53. myBasicGrid->addWidget(divButton,3,4);
    54. myBasicGrid->addWidget(addButton,4,3);
    55. myBasicGrid->addWidget(subButton,4,4);
    56. myBasicGrid->addWidget(pointButton,5,1);
    57. myBasicGrid->addWidget(lnButton,5,2);
    58. myBasicGrid->addWidget(ansButton,5,3);
    59. myBasicGrid->addWidget(equalButton,5,4);
    60. }
    61.  
    62. //Slots implemetation
    63. void MyCalculator::digitClicked()
    64. {
    65. }
    66. void MyCalculator::operationClicked()
    67. {
    68. }
    69. void MyCalculator::functionClicked()
    70. {
    71. }
    72. void MyCalculator::equalClicked()
    73. {
    74. }
    75. void MyCalculator::pointClicked()
    76. {
    77. }
    78.  
    79. void MyCalculator::clearClicked()
    80. {
    81. }
    82. void MyCalculator::delClicked()
    83. {
    84. }
    85. void MyCalculator::ansClicked()
    86. {
    87. }
    88. //functions implimintation
    89. QPushButton *MyCalculator::createButton(const QString &text, const char *buttonSlot){
    90. QPushButton *button = new QPushButton(text);
    91. connect(button, SIGNAL(clicked()), this, buttonSlot);
    92. return button;
    93. }
    To copy to clipboard, switch view to plain text mode 
    and the display.h file // another class I created and Inherited form QTextEdit
    Qt Code:
    1. #ifndef DISPLAY_H
    2. #define DISPLAY_H
    3.  
    4. #include <QTextEdit>
    5.  
    6. class Display : public QTextEdit
    7. {
    8. Q_OBJECT
    9. public:
    10. explicit Display(QWidget *parent = 0);
    11. };
    12. #endif // DISPLAY_H
    To copy to clipboard, switch view to plain text mode 

    the display.cpp file
    Qt Code:
    1. ]
    2. #include "display.h"
    3.  
    4. Display::Display(QWidget *parent) :
    5. QTextEdit(parent)
    6. {
    7. }
    To copy to clipboard, switch view to plain text mode 
    And here is the error
    Qt Code:
    1. : error LNK2019: unresolved external symbol "public: __thiscall Display::Display(class QWidget *)" (??0Display@@QAE@PAVQWidget@@@Z) referenced in function "public: __thiscall MyCalculator::MyCalculator(class QWidget *)" (??0MyCalculator@@QAE@PAVQWidget@@@Z)
    2. debug\first.exe : fatal error LNK1120: 1 unresolved externals
    3. jom: C:\Users\FBM\Desktop\Calculator\first-build-Desktop_Qt_5_0_1_MSVC2010_32bit-debug\Makefile.Debug [debug\first.exe] Error 1120
    To copy to clipboard, switch view to plain text mode 

    When I comment the code in line 13 of the .cpp file the program works fine.
    Any help plz

  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: error LNK2019: unresolved external symbol

    Run a clean rebuild of the program including rerunning qmake.

  3. The following 2 users say thank you to ChrisW67 for this useful post:

    Baso (8th February 2013), sami1592 (2nd February 2016)

  4. #3
    Join Date
    Feb 2013
    Posts
    28
    Thanks
    13
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: error LNK2019: unresolved external symbol

    I just deleted the build folder, restart the computer,rebuild and It did work.

Similar Threads

  1. error LNK2019: unresolved external symbol
    By 8080205 in forum Newbie
    Replies: 3
    Last Post: 3rd October 2012, 15:53
  2. Help - LNK2019: Unresolved external symbol
    By marc2050 in forum Newbie
    Replies: 3
    Last Post: 17th May 2011, 01:29
  3. Replies: 3
    Last Post: 29th April 2011, 09:13
  4. Replies: 4
    Last Post: 5th January 2011, 15:51
  5. Replies: 1
    Last Post: 10th April 2009, 18:07

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.