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. linker errors for QWidget

linker errors for QWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 927 Views 1 Watching
  • 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.
  • M Offline
    M Offline
    MohsinM.
    wrote on last edited by
    #1

    I am getting ~40 or so linker errors for QWidget - examples below.

    VS 2017 project is referencing Qt5Guid.lib with directory: C:\Qt\Qt-5.12.1\lib
    qt5Guid.lib file is present 9,452 kb
    Other QT5 libs are being detected fine (ex: Qt5Cored.lib, Qt5OpenGLd.lib)

    Error LNK2001 unresolved external symbol "protected: virtual void __thiscall QWidget::actionEvent(class QActionEvent *)" (?actionEvent@QWidget@@MAEXPAVQActionEvent@@@Z) SandBoxGame C:\Projects\SandBoxGame\main.obj 1
    Error LNK2001 unresolved external symbol "protected: virtual void __thiscall QWidget::changeEvent(class QEvent *)" (?changeEvent@QWidget@@MAEXPAVQEvent@@@Z) SandBoxGame C:\Projects\SandBoxGame\main.obj 1
    Error LNK2001 unresolved external symbol "protected: virtual void __thiscall QWidget::closeEvent(class QCloseEvent *)" (?closeEvent@QWidget@@MAEXPAVQCloseEvent@@@Z) SandBoxGame C:\Projects\SandBoxGame\main.obj 1

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

      Hi,

      Did you add QT += widgets to your .pro file ?
      If so, did you then run qmake before building ?

      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
      0
      • M Offline
        M Offline
        MohsinM.
        wrote on last edited by
        #3

        Didn't use pro file. Background and code if it helps:
        needed opengl desktop so did the following:
        download source code for 5.12.1
        open VS 2017 developer cmd
        cd C:\Qt\5.12.1\Src
        configure -debug-and-release -opengl desktop
        nmake
        nmake install

        main.cpp
        #include <QtWidgets\qapplication.h>
        #include "myGlWindow.h"

        int main(int argc, char* argv[])
        {
        QApplication application(argc, argv);
        MyGlWindow myGlWindow;
        myGlWindow.show();

        return application.exec();
        

        }

        myglwindow.h

        #ifndef MY_GL_WINDOW
        #define MY_GL_WINDOW
        #include <QtOpenGL\QGLWidget>
        #include <QtCore\qtimer.h>

        class MyGlWindow : public QGLWidget
        {
        Q_OBJECT

        GLuint vertexBufferID;
        QTimer myTimer;
        

        protected:
        void initializedGL();
        void paintGL();
        private slots:
        void myUpdate();
        };

        #endif // !MY_GL_WINDOW

        myglwindow.cpp
        #include <GL\glew.h>
        #include <cassert>
        #include "myGlWindow.h"

        void MyGlWindow::initializedGL()
        {

        GLenum errorCode = glewInit();
        assert(errorCode == 0);
        
        glGenBuffers(1, &vertexBufferID);
        glBindBuffer(GL_ARRAY_BUFFER, vertexBufferID);
        
        float verts[] =
        {
        	+0.0f, +0.1f,
        	-0.1f, -0.1f,
        	+0.1f, -0.1f
        };
        
        glBufferData(GL_ARRAY_BUFFER, sizeof(verts),
        	verts, GL_STATIC_DRAW);
        
        bool keepRunning = true;
        while (keepRunning)
        {
        	myUpdate();
        }
        
        connect(&myTimer, SIGNAL(timeout()),
        	this, SLOT(myUpdate()));
        myTimer.start(0);
        

        }

        void MyGlWindow::paintGL()
        {
        glClear(GL_COLOR_BUFFER_BIT);
        glEnableVertexAttribArray(0);
        glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);
        glDrawArrays(GL_TRIANGLES, 0, 3);
        }

        void MyGlWindow::myUpdate()
        {
        }

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

          There's no need to re-build Qt for that, you can for the backend to use desktop OpenGL on Windows.

          If you don't use any .pro file what are you using to manage your project ?

          In any case, you have to link against the Qt 5 Widgets library.

          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
          0
          • M Offline
            M Offline
            MohsinM.
            wrote on last edited by
            #5

            @SGaist said in linker errors for QWidget:

            y .pro file what are you using to manage your project ?
            In any case, you have to link against the

            I'm using VS 2017 - 15.9.6

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

              Then add the Qt Widget module to the list of dependencies of your project.

              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
              0

              • Login

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