Linker Error Undefined Reference To Vtable For Mainwindow
Contents |
here for a quick overview of the site Help Center Detailed answers to undefined reference to vtable qt cmake any questions you might have Meta Discuss the workings and
Undefined Reference To Vtable Qt Qobject
policies of this site About Us Learn more about Stack Overflow the company Business Learn qt undefined reference to vtable for class more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community qt undefined reference to vtable for constructor Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Qt Linker Error: “undefined reference to vtable” up vote 31 down vote favorite 7 This is my header: #ifndef BARELYSOCKET_H #define BARELYSOCKET_H #include
Undefined Reference To Vtable For Class Qobject
Draw of the BarelySocket! class BarelySocket: public QObject { Q_OBJECT public: BarelySocket(); public slots: void sendMessage(Message aMessage); signals: void reciveMessage(Message aMessage); private: // QVector
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of undefined reference to metaobject const this site About Us Learn more about Stack Overflow the company Business qt undefined reference to signal Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask
The Vtable Symbol May Be Undefined Because The Class Is Missing Its Key Function
Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign http://stackoverflow.com/questions/2555816/qt-linker-error-undefined-reference-to-vtable up undefined reference to `vtable for MainWindow' up vote 1 down vote favorite I'm following Qt's guide for using a QPushButton. I did exactly as the guide suggests, but I'm getting a compilation error: ./src/mainwindow.o: In function `MainWindow::MainWindow(QWidget*)': mainwindow.cpp:(.text+0x1d): undefined reference to `vtable for MainWindow' ./src/mainwindow.o:mainwindow.cpp:(.text+0x25): more undefined references to `vtable for MainWindow' follow collect2: error: ld returned 1 exit status make: *** http://stackoverflow.com/questions/33633056/undefined-reference-to-vtable-for-mainwindow [HelloWorldProj] Error 1 I tried adding a destructor: ~MainWindow(){}; but the problem persisted. I have no virtual functions declared, except one function inside QMainWindow (the class I'm inheriting from): virtual QMenu *createPopupMenu(); Should this be defined in my class? c++ eclipse qt share|improve this question asked Nov 10 '15 at 15:04 Alaa M. 71631229 Add Q_OBJECT to your class declaration, run qmake and build again. –vahancho Nov 10 '15 at 15:06 I have a Q_OBJECT: class MainWindow : public QMainWindow { Q_OBJECT...} –Alaa M. Nov 10 '15 at 15:07 Improve your question. –KernelPanic Nov 10 '15 at 15:08 My exact code is like the linked website. There's nothing I can add to my question... –Alaa M. Nov 10 '15 at 15:12 @AlaaM. See my updated answer –The Badger Nov 10 '15 at 15:23 | show 1 more comment 1 Answer 1 active oldest votes up vote 3 down vote accepted Try running qmake on the project and then do a rebuild. Your example is broken (I will update it shortly if possible) Create an empty file and
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings http://stackoverflow.com/questions/19761767/qt-5-cmake-fails-with-undefined-reference-to-vtable-on-hello-world-with-inc-sr and policies of this site About Us Learn more about Stack Overflow http://www.qtcentre.org/threads/685-linker-error-undefined-reference-to-vtable-for-MainWindow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only undefined reference takes a minute: Sign up Qt 5 cmake fails with undefined reference to vtable on hello world with inc & src as subdirs up vote 6 down vote favorite 1 Update 2 After messing around a bit (and some editing of the generated Makefiles), it looks like what is happening is that moc is not properly processing MainWindow.h (included by undefined reference to main.cpp and MainWindow.cpp unless it is in the same folder as the source files which included it. Moc runs on MainWindow.cpp, doesn't process the include and thus doesn't see the Q_OBJECT macro so proceeds to produce an empty output file. I'm not sure whether moc usually processes includes or if it just scans the directory, but either way, headers that need mocing but are in other directories are not being processed! Update The problem appears to be related to the output produced by moc. In the first case (the one that compiles), hello-world_automoc.cpp and moc_MainWindow.cpp are generated. hello-world_automoc.cpp looks like /* This file is autogenerated, do not edit*/ #include "moc_MainWindow.cpp" In the second case, a hello-world_automoc.cpp is produced that looks like /* This file is autogenerated, do not edit*/ enum some_compilers { need_more_than_nothing }; and there is no moc_MainWindow.cpp at all. If I manually call moc in from cmake instead of using automoc in the broken case, I do get moc_MainWindow.cpp but it is empty. Original Status Firstly, no, I haven't forgotten to set(CMAKE_AUTOMOC ON). Also note that MainWindow's destructor
to vtable for MainWindow If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Welcome to Qt Centre. Qt Centre is a community site devoted to programming in C++ using the Qt framework. Over 90 percent of questions asked here gets answered. If you are looking for information about Qt related issue — register and post your question. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. + Reply to Thread Results 1 to 6 of 6 Thread: linker error: undefined reference to vtable for MainWindow Thread Tools Show Printable Version Subscribe to this Thread… Search Thread Advanced Search Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 14th February 2006,22:59 #1 Morea View Profile View Forum Posts View Blog Entries View Articles Intermediate user Join Date Feb 2006 Posts 209 Thanks 13 Qt products Platforms linker error: undefined reference to vtable for MainWindow (subject) is the error I get when compiling the same program that compiled without problems in qt 4.0.1 and dev-c++. Now I use qt 4.1.0. Perhaps I need to reboot windows? Any better ideas? The strange thing is that I haven't changed anythi