Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. error LNK2019: unresolved external symbol
Forum Update on Monday, May 27th 2025

error LNK2019: unresolved external symbol

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 5 Posters 4.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    js6033
    wrote on last edited by
    #1

    Hi,
    As a beginner I read Qt for Beginners. All works well until point 10 Subclassing QWidget. When I enter code and try to compile I get 'error LNK2019: unresolved external symbol "public: __thiscall Window::Window(class QWidget *)" (??0Window@@QAE@PAVQWidget@@@Z) referenced in function _main'.
    How do I solve the error?
    /Jonny

    kshegunovK 1 Reply Last reply
    0
    • J js6033

      Hi,
      As a beginner I read Qt for Beginners. All works well until point 10 Subclassing QWidget. When I enter code and try to compile I get 'error LNK2019: unresolved external symbol "public: __thiscall Window::Window(class QWidget *)" (??0Window@@QAE@PAVQWidget@@@Z) referenced in function _main'.
      How do I solve the error?
      /Jonny

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      Hi,

      js6033 said in error LNK2019: unresolved external symbol:

      How do I solve the error?

      It's basic C++ and has little to do with Qt. You need to provide a body for the class' constructor. You have provided only declaration and when the linker runs it can't find the symbol so it complains.

      Kind regards.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      2
      • J Offline
        J Offline
        js6033
        wrote on last edited by
        #3

        But what should I do? I am reading tutorial for beginner and enter code exactly as in the tutorial.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Which tutorial is it ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • A Offline
            A Offline
            ambershark
            wrote on last edited by
            #5

            Show us the code and compile/link command and we can tell ya what's wrong. :)

            My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

            1 Reply Last reply
            1
            • J Offline
              J Offline
              js6033
              wrote on last edited by
              #6

              tutorial at https://wiki.qt.io/Qt_for_Beginners
              down to point 10 Subclassing QWidget are the codes.

              kshegunovK 1 Reply Last reply
              0
              • J js6033

                tutorial at https://wiki.qt.io/Qt_for_Beginners
                down to point 10 Subclassing QWidget are the codes.

                kshegunovK Offline
                kshegunovK Offline
                kshegunov
                Moderators
                wrote on last edited by
                #7

                @js6033 said in error LNK2019: unresolved external symbol:

                tutorial at https://wiki.qt.io/Qt_for_Beginners
                down to point 10 Subclassing QWidget are the codes.

                Do you have:

                Window::Window(QWidget *parent) :
                 QWidget(parent)
                {
                    // ...
                }
                

                in your cpp file?

                Read and abide by the Qt Code of Conduct

                1 Reply Last reply
                1
                • A Offline
                  A Offline
                  ambershark
                  wrote on last edited by
                  #8

                  This was taken from that tutorial:

                  window.cpp
                  
                  #include "window.h"
                  #include <QPushButton>
                   
                  Window::Window(QWidget *parent) :
                   QWidget(parent)
                   {
                   // Set size of the window
                   setFixedSize(100, 50);
                   
                   // Create and position the button
                   m_button = new QPushButton("Hello World", this);
                   m_button->setGeometry(10, 10, 80, 30);
                  }
                  

                  If you have that window.cpp file and the code is in it like that then you just didn't include it in your build.

                  Make sure that the window.cpp file is being built and linked to the main executable in your project.

                  My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                  1 Reply Last reply
                  2
                  • G Offline
                    G Offline
                    GDLahiru
                    wrote on last edited by
                    #9

                    Delete previously created files from the build, And then run again.

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved