Results 1 to 4 of 4

Thread: Compilation Error LNK2019

  1. #1
    Join Date
    Dec 2012
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Compilation Error LNK2019

    I got this compilation error.

    When I try to debug, I got these errors.

    Error.jpg

    main.obj:-1: error: LNK2019: unresolved external symbol "public: void __thiscall Keyboard::setWidget(class QWidget *)" (?setWidget@Keyboard@@QAEXPAVQWidget@@@Z) referenced in function _main

    main.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall Keyboard::Keyboard(class QObject *)" (??0Keyboard@@QAE@PAVQObject@@@Z) referenced in function _main

    And the source come from this code.

    Qt Code:
    1. Keyboard::Keyboard(QObject *parent) : QObject(parent)
    2. {
    3. theWidget = NULL;
    4. }
    5.  
    6. void Keyboard::setWidget(QWidget* theWidget)
    7. {
    8. this->theWidget = theWidget;
    9. }
    To copy to clipboard, switch view to plain text mode 


    I hope someone can tell me whether I got missing any things
    or I need to change some things in the Build Setting.
    Thank you

  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: Compilation Error LNK2019

    Assuming that the Keyboard class is in a library, and the errors arise from trying to use it from outside the library, you need to ensure the library can be found in with entries in LIBS (see Declaring Other Libraries) and export the symbols (see Using Symbols from Shared Libraries)

  3. #3
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Compilation Error LNK2019

    thats a linker error, not a compiler error.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  4. #4
    Join Date
    Dec 2012
    Posts
    6
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Compilation Error LNK2019

    hey i had the same problem. The code was compiling in Qt rc2 and threw unresolved externals when Qt 5 got released.
    In RC2 I had set up compiler kit that was pointing towards my vs2010 because the default one didn't work. When Qt 5.0 got released my kit stopped working and the default one became functional instead. I don't know why because their settings were identical.

    So if you did same try adding the default kit in your project settings. (button Projects on the left side of Creator and the AddKit button)

Similar Threads

  1. error LNK2019: unresolved external symbol
    By 8080205 in forum Newbie
    Replies: 3
    Last Post: 3rd October 2012, 15:53
  2. Replies: 3
    Last Post: 29th April 2011, 09:13
  3. Replies: 4
    Last Post: 5th January 2011, 15:51
  4. Replies: 1
    Last Post: 10th April 2009, 18:07
  5. compilation error
    By jjbabu in forum Qt Programming
    Replies: 19
    Last Post: 9th April 2009, 07:03

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.