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. [SOLVED] Undefined reference for « vtable for myGLWidget »
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Undefined reference for « vtable for myGLWidget »

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 2.7k 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.
  • B Offline
    B Offline
    blacksqd
    wrote on last edited by
    #1

    Hi,

    first of all, I'm sorry but I don't use QtCreator. At the beginning, my project didn't need Qt so I began on the IDE NetBeans.

    So this is my problem.

    Here is the code : myGLWidget.h

    @#ifndef MYGLWIDGET_H
    #define MYGLWIDGET_H

    #include <QGLWidget>
    #include <QTimer>
    #include <QKeyEvent>

    class myGLWidget : public QGLWidget
    {
    Q_OBJECT
    public:
    explicit myGLWidget(int framesPerSecond = 0, QWidget *parent = 0, char *name = 0);
    virtual void initializeGL() = 0;
    virtual void resizeGL(int width, int height) = 0;
    virtual void paintGL() = 0;
    virtual void keyPressEvent( QKeyEvent *keyEvent );

    public slots:
    virtual void timeOutSlot();

    private:
    QTimer *t_Timer;

    };

    #endif // MYGLWIDGET_H@

    And myGLWidget.cpp :

    @#include "myGLWidget.h"

    myGLWidget::myGLWidget(int framesPerSecond, QWidget *parent, char *name) :
    QGLWidget(parent)
    {
    setWindowTitle(QString::fromUtf8(name));
    if(framesPerSecond == 0)
    t_Timer = NULL;
    else
    {
    int seconde = 1000; // 1 seconde = 1000 ms
    int timerInterval = seconde / framesPerSecond;
    t_Timer = new QTimer(this);
    connect(t_Timer, SIGNAL(timeout()), this, SLOT(timeOutSlot()));
    t_Timer->start( timerInterval );
    }
    }

    void myGLWidget::timeOutSlot()
    {
    }@

    On the properties, I have :

    C++ Compiler :
    Include Directories :
    ../../Qt/5.4/gcc_64/include
    ../../Qt/5.4/gcc_64/include/QtCore
    ../../Qt/5.4/gcc_64/include/QtGui
    ../../Qt/5.4/gcc_64/include/QtNetwork
    ../../Qt/5.4/gcc_64/include/QtQuick
    ../../Qt/5.4/gcc_64/include/QtQml
    ../../Qt/5.4/gcc_64/include/QtWidget

    And in the linker :
    Directories:
    ../../Qt/5.4/gcc_64/lib

    Libraries:
    Qt5Core
    Qt5Gui
    Qt5Network
    Qt5Qml
    Qt5OpenGL
    Qt5OpenGLExtension
    Qt5Quick
    Qt5Widget

    I also have an run-time directory for the librairies :
    ../../Qt/5.4/gcc_64/lib

    That's it. And I use QT 5.4.

    So the problem is when I run the project. Here is the error :

    @"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
    make[1]: entrant dans le répertoire « /home/sim/NetBeansProjects/KinectProjectMa1 »
    "/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/kinectprojectma1
    make[2]: entrant dans le répertoire « /home/sim/NetBeansProjects/KinectProjectMa1 »
    mkdir -p dist/Debug/GNU-Linux-x86
    g++ -fPIC -o dist/Debug/GNU-Linux-x86/kinectprojectma1 build/Debug/GNU-Linux-x86/_ext/1729875118/moc_discovery.o build/Debug/GNU-Linux-x86/_ext/1729875118/moc_huebridgeconnection.o build/Debug/GNU-Linux-x86/_ext/1729875118/moc_light.o build/Debug/GNU-Linux-x86/_ext/1729875118/moc_lightinterface.o build/Debug/GNU-Linux-x86/_ext/1729875118/moc_lights.o build/Debug/GNU-Linux-x86/Device.o build/Debug/GNU-Linux-x86/KinectDisplay.o build/Debug/GNU-Linux-x86/LedDevice.o build/Debug/GNU-Linux-x86/ListDevice.o build/Debug/GNU-Linux-x86/RgbDevice.o build/Debug/GNU-Linux-x86/SoundDevice.o build/Debug/GNU-Linux-x86/discovery.o build/Debug/GNU-Linux-x86/huebridgeconnection.o build/Debug/GNU-Linux-x86/light.o build/Debug/GNU-Linux-x86/lights.o build/Debug/GNU-Linux-x86/main.o build/Debug/GNU-Linux-x86/myGLWidget.o -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu -L../../Qt/5.4/gcc_64/lib -Wl,-rpath,../../Qt/5.4/gcc_64/lib -lGLU -lglut -lopenal -lOpenNI -lGL -lalut -lQt5Core -lQt5Gui -lQt5OpenGL -lQt5OpenGLExtensions -lQt5Network -lQt5Qml -lQt5Quick -lQt5Widgets -lQtCore -lQtGui -lQtNetwork -lQtOpenGL
    build/Debug/GNU-Linux-x86/myGLWidget.o: dans la fonction « myGLWidget::myGLWidget(int, QWidget*, char*) »:
    /home/sim/NetBeansProjects/KinectProjectMa1/myGLWidget.cpp:11: référence indéfinie vers « vtable for myGLWidget »
    /home/sim/NetBeansProjects/KinectProjectMa1/myGLWidget.cpp:11: référence indéfinie vers « vtable for myGLWidget »
    collect2: error: ld returned 1 exit status
    make[2]: *** [dist/Debug/GNU-Linux-x86/kinectprojectma1] Erreur 1
    make[2]: quittant le répertoire « /home/sim/NetBeansProjects/KinectProjectMa1 »
    make[1]: *** [.build-conf] Erreur 2
    make[1]: quittant le répertoire « /home/sim/NetBeansProjects/KinectProjectMa1 »
    make: *** [.build-impl] Erreur 2@

    As you guess, I don't know why I have this error. If you could help me !

    Thank you

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

      Hi and welcome to devnet,

      You likely added the Q_OBJECT macro after first building your software. Re-run qmake and build again. You whould then be good to go

      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
      • B Offline
        B Offline
        blacksqd
        wrote on last edited by
        #3

        Thank you for your quick response.
        I guess I juste have to run qmake on my project's directory ? (with no option ?)
        I just tried but after that, I got a new weird error.

        In another file on my project I have :

        @#include <XnCppWrapper.h>@

        situated here : ./usr/include/ni/XnCppWrapper.h

        And in my include directories I have : ./usr/include/ni

        And when I run the project I got :

        @g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o Device.o Device.cpp
        In file included from Device.cpp:8:0:
        Device.h:11:26: fatal error: XnCppWrapper.h: Aucun fichier ou dossier de ce type
        ^
        compilation terminated.
        @

        I guess I made a mistake with qmake ?

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

          Do you have that path in your pro file ?

          Something like:
          @
          INCLUDEPATH += /usr/include/ni
          @

          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
          • B Offline
            B Offline
            blacksqd
            wrote on last edited by
            #5

            I added it.
            To make it easier, I create a new project on QtCreator.
            I added all the librairies (I think) by right clicking on the project, add librairies, extern librairies ...
            So the last error are correct now. I have a last one and a 'warning'.

            Now this line
            @virtual void keyPressEvent( QKeyEvent keyEvent );@
            in my file above give me an error :
            @/home/sim/build-ProjectMA1-Desktop_Qt_5_4_0_GCC_64bit-Debug/moc_myglwidget.o:-1: erreur : undefined reference to `myGLWidget::keyPressEvent(QKeyEvent
            )'@

            And the warning is :
            @The /home/sim/build-ProjectMA1-Desktop_Qt_5_4_0_GCC_64bit-Debug/moc_huebridgeconnection.cpp file was deleted outside of Qt Creator. Do you want to save it under a different name or close the editor?@

            but I didn't touch anything ...

            Thank for your help

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

              You didn't implement keyPressEvent

              moc files are regenerated when you modify your class so if you happen to have it opened in Qt Creator you will have this warning

              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
              • B Offline
                B Offline
                blacksqd
                wrote on last edited by
                #7

                Everything works, thank you very much !

                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