Question:
QT compilation error:
error: undefined reference to `vtable ...`
reason:
1.Qt uses signals and slots to implement communication features.
2.Signals and slots can be used when the class is derived from QObject and the Q_OBJECT macro is added to the header file.
3.When Q_OBJECT is added to the class header file QtCreator will automatically create a moc_***.cpp file that implements the code for signal and slot communication.
4.However, sometimes when we create a class through QtCreator without selecting the IDE option to derive it from the QObject class, but add it later, QtCreator will not automatically create the moc_***.cpp file. In this case it will report an error: undefined reference to `vtable for ***.
Solution:
According to various online methods, it can not be solved, nor can rebuild
mine is a small project. Just delete the build-XXX
folder and rebuild it.
Read More:
- [Solved] Qt Error: undefined reference to xxxxx
- C++Qt development – Qtsocket programming error: undefined reference to `_imp__WSAStartup
- [Solved] QT Error: error: undefined reference to `GameModel::~GameModel()’
- [Solved] C++ error: undefined reference to `xxx‘
- error: undefined reference to `calculate()` [How to Solve]
- Clion new method shows undefined reference to solution
- [Solved] cortex_M3 freeRTOS Error: undefined reference to `_sbrk‘
- GCC Error:(.text+0x24): undefined reference to `main‘collect2: error: ld returned 1 exit status [Solved]
- [Solved] Compile Error: undefined reference to `google::FlagRegisterer::FlagRegisterer
- [Solved] PCL Compile Error: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>:: XXX
- [Solved] VScode Error: undefined reference to ‘WinMain’ collect2.exe: error: ld returned 1 exit status
- [Solved] Compile the program error: undefined reference to `cv::dnn::dnn4_v20210301::Net::~Net()‘
- [Solved] target_link_libraries error: a missing vtable usually means the first non-inline virtual member function has no definition.
- [Solved] Qt Error: qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed
- [Solved] qt phonon Play wav file Error:“symbol lookup error: /usr/lib/kde4/plugins/phonon_backend/phonon_gstreamer.so: undefined symbol: _ZNK6Phonon11MediaSource3mrlEv”
- [Solved] QT error: the packaged exe of Enigma virtual box reports an error cannot load library qt5core.dll
- How to Solve Kotlin unresolved reference error
- Angular_ Error: Cannot assign to a reference or variable!
- [Solved] QT Programme Error: error: no matching function for call to…
- QT Error: Failed to create vertex shader [Three Methods to Fix]