Results 1 to 4 of 4

Thread: undefined reference to `vtable for ... ', specific for QT projects...

  1. #1
    Join Date
    Sep 2009
    Location
    Surrey, BC, Canada
    Posts
    110
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    1
    Thanked 2 Times in 1 Post

    Default undefined reference to `vtable for ... ', specific for QT projects...

    Seriously have no idea why this happens, particularly, always happening in QT projects.


    Qt Code:
    1. ../utils/bin/Debug/libutils.a(ImageView.o): In function `CImageView':
    2. /home/jiapei/MyPrograms/codeblocks/aam/utils/src/ImageView.cpp:13: undefined reference to `vtable for CImageView'
    3. /home/jiapei/MyPrograms/codeblocks/aam/utils/src/ImageView.cpp:13: undefined reference to `vtable for CImageView'
    4. /home/jiapei/MyPrograms/codeblocks/aam/utils/src/ImageView.cpp:13: undefined reference to `vtable for CImageView'
    5. /home/jiapei/MyPrograms/codeblocks/aam/utils/src/ImageView.cpp:13: undefined reference to `vtable for CImageView'
    6. ../utils/bin/Debug/libutils.a(ImageView.o): In function `~CImageView':
    7. /home/jiapei/MyPrograms/codeblocks/aam/utils/src/ImageView.cpp:23: undefined reference to `vtable for CImageView'
    8. ../utils/bin/Debug/libutils.a(ImageView.o):/home/jiapei/MyPrograms/codeblocks/aam/utils/src/ImageView.cpp:23: more undefined references to `vtable for CImageView' follow
    9. collect2: ld returned 1 exit status
    10. make: *** [objdetection] Error 1
    To copy to clipboard, switch view to plain text mode 


    It seems to tell than CImageView is missing something .

    My CImageView is defined as:


    Qt Code:
    1. #ifndef __IMAGEVIEW_QT__
    2. #define __IMAGEVIEW_QT__
    3.  
    4. #include <QGraphicsView>
    5. #include <QLabel>
    6. #include <QBoxLayout>
    7.  
    8.  
    9. #include "cv.h"
    10. #include "highgui.h"
    11.  
    12. using namespace std;
    13. using namespace cv;
    14.  
    15. /**
    16. show an image in the corresponding wxWindow
    17. */
    18. class CImageView : public QGraphicsView
    19. {
    20. Q_OBJECT
    21.  
    22. private:
    23. bool m_isDrawing;
    24. QGraphicsScene* m_QTScene;
    25. QImage* m_QTImage;
    26. protected:
    27. void paintEvent(QPaintEvent *event);
    28.  
    29. public:
    30. CImageView( QWidget *parent = 0 );
    31. virtual ~CImageView( );
    32.  
    33. //CImageView& operator=(const CImageView& iImgView);
    34.  
    35. void putImage(const Mat& image);
    36. };
    37.  
    38. #endif // __IMAGEVIEW_QT__
    To copy to clipboard, switch view to plain text mode 

    And, I'm pretty sure that none of the functions is not defines.
    Namely, all declared functions have been defined in .cpp files !!!!

    So, the only possibility is " QGraphicsView " is not defined.


    Am I correct? How to avoid such error messages ?

    Please do help !!!

    Best Regards
    JIA
    Welcome to Vision Open
    http://www.visionopen.com

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: undefined reference to `vtable for ... ', specific for QT projects...

    Rerun qmake after adding the Q_OBJECT macro to an existing file and make sure all virtual methods that are declared, are also implemeneted.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Sep 2009
    Location
    Surrey, BC, Canada
    Posts
    110
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    1
    Thanked 2 Times in 1 Post

    Default Re: undefined reference to `vtable for ... ', specific for QT projects...

    Yes, as you might have seen in my header file

    Qt Code:
    1. #ifndef __IMAGEVIEW_QT__
    2. #define __IMAGEVIEW_QT__
    3.  
    4. #include <QGraphicsView>
    5. #include <QLabel>
    6. #include <QBoxLayout>
    7.  
    8.  
    9. #include "cv.h"
    10. #include "highgui.h"
    11.  
    12. using namespace std;
    13. using namespace cv;
    14.  
    15. /**
    16. show an image in the corresponding wxWindow
    17. */
    18. class CImageView : public QGraphicsView
    19. {
    20. [SIZE="6"][B]Q_OBJECT // declared !!!!!!!!![/B][/SIZE]
    21.  
    22. private:
    23. bool m_isDrawing;
    24. QGraphicsScene* m_QTScene;
    25. QImage* m_QTImage;
    26. protected:
    27. void paintEvent(QPaintEvent *event);
    28.  
    29. public:
    30. CImageView( QWidget *parent = 0 );
    31. virtual ~CImageView( );
    32.  
    33. //CImageView& operator=(const CImageView& iImgView);
    34.  
    35. void putImage(const Mat& image);
    36. };
    37.  
    38. #endif // __IMAGEVIEW_QT__
    To copy to clipboard, switch view to plain text mode 


    What's more, the only virtual function (destructor) has been absolutely defined in the .cpp file as:

    Qt Code:
    1. CImageView::~CImageView( )
    2. {
    3. if(this->m_QTImage) delete (this->m_QTImage);
    4. if(this->m_QTScene) delete (this->m_QTScene);
    5. }
    To copy to clipboard, switch view to plain text mode 


    Why QT always brings such kind of weird error messages, while other projects don't ?
    Any more detailed explanation what's actually happening inside QT project that might have caused this?


    Cheers
    JIA



    Quote Originally Posted by wysota View Post
    Rerun qmake after adding the Q_OBJECT macro to an existing file and make sure all virtual methods that are declared, are also implemeneted.
    Welcome to Vision Open
    http://www.visionopen.com

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: undefined reference to `vtable for ... ', specific for QT projects...

    Quote Originally Posted by jiapei100 View Post
    Yes, as you might have seen in my header file
    I asked you if you ran qmake after setting the macro and not if you declared it.

    Why QT always brings such kind of weird error messages, while other projects don't ?
    Ask Apple, QuickTime is their product.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. undefined reference to vtable in Threads.
    By prasanth.nvs in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 20th February 2009, 10:19
  2. Undefined reference to 'vtable for XXX'
    By Sheng in forum Qt Programming
    Replies: 4
    Last Post: 17th October 2008, 15:59
  3. undefined reference to vtable
    By renjithmamman in forum Qt Programming
    Replies: 5
    Last Post: 2nd July 2006, 04:23
  4. Replies: 2
    Last Post: 30th June 2006, 18:42

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
  •  
Qt is a trademark of The Qt Company.