{"id":625,"date":"2022-08-30T15:04:28","date_gmt":"2022-08-30T15:04:28","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/linker-error-undefined-reference-to-vtable-of-qglviewer-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:04:28","modified_gmt":"2022-08-30T15:04:28","slug":"linker-error-undefined-reference-to-vtable-of-qglviewer-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/linker-error-undefined-reference-to-vtable-of-qglviewer-collection-of-common-programming-errors\/","title":{"rendered":"linker error: undefined reference to `vtable of QGLViewer\u2019-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m working on a visualization project. It should view a 3d model on a QGLViewer. I have a subclass of QGLViewer defined like this:<\/p>\n<pre><code>class GLViewer : public QGLViewer\n{\n    Q_OBJECT\npublic:\n    explicit GLViewer(QWidget *parent = 0,const QGLWidget* shareWidget=0, Qt::WFlags flags=0);\nprotected:\n    void initializeGL();\n    void resizeGL(int width, int height);\n    void paintGL();\nsignals:\npublic slots:\n};\n<\/code><\/pre>\n<p>Implementing the c\u2019tor like this:<\/p>\n<pre><code>GLViewer::GLViewer(QWidget *parent, const QGLWidget* shareWidget, Qt::WFlags flags):\n    QGLViewer(parent,shareWidget,flags)\n{\n}\n<\/code><\/pre>\n<p>I\u2019m getting linker error:<\/p>\n<pre><code>glviewer.o: In function `GLViewer::GLViewer(QWidget*, QGLWidget const*, QFlags)':\nglviewer.cpp:(.text+0x18): undefined reference to `vtable for GLViewer'\nglviewer.cpp:(.text+0x20): undefined reference to `vtable for GLViewer'\n<\/code><\/pre>\n<p><strong>EDIT:<\/strong> This is content of <code>.pro<\/code> file:<\/p>\n<pre><code>QT       += core gui opengl xml\n\nTARGET = qglviewer-test\nTEMPLATE = app\n\nLIBS += -lqglviewer-qt4 -lGLU -lGLEW\n\nSOURCES += main.cpp\\\n        mainwindow.cpp \\\n        glviewer.cpp\n\nHEADERS  += mainwindow.h \\\n        glviewer.cpp\n<\/code><\/pre>\n<p>FORMS += mainwindow.ui<\/p>\n<ol>\n<li>\n<p>You were not running glviewer.h through moc. That&#8217;s what the error is saying. In your .pro file, change<\/p>\n<pre><code>HEADERS  += mainwindow.h \\\n        glviewer.cpp\n<\/code><\/pre>\n<p>to<\/p>\n<pre><code>HEADERS  += mainwindow.h \\\n        glviewer.h<\/code><\/pre>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-09 21:08:40. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I&#8217;m working on a visualization project. It should view a 3d model on a QGLViewer. I have a subclass of QGLViewer defined like this: class GLViewer : public QGLViewer { Q_OBJECT public: explicit GLViewer(QWidget *parent = 0,const QGLWidget* shareWidget=0, Qt::WFlags flags=0); protected: void initializeGL(); void resizeGL(int width, int height); void paintGL(); signals: public slots: }; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-625","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/625","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=625"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/625\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=625"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=625"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=625"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}