QT报错:undefined reference to vtable for (class name)

博客指出类存在问题的两个原因,一是类中的虚函数没有函数体,二是类中有虚函数但没有虚析构函数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原因:

1.类中的虚函数没有函数体.

2.类中有虚函数,没有虚析构函数.

[ 19%] Linking CXX executable test_FaultInjectionConfigTable.exe CMakeFiles\test_FaultInjectionConfigTable.dir/objects.a(mocs_compilation.cpp.obj):mocs_compilation.cpp:(.text+0x4a91): undefined reference to `NetworkInterface::qt_metacast(char const*)' CMakeFiles\test_FaultInjectionConfigTable.dir/objects.a(mocs_compilation.cpp.obj):mocs_compilation.cpp:(.text+0x4acb): undefined reference to `NetworkInterface::qt_metacall(QMetaObject::Call, int, void**)' CMakeFiles\test_FaultInjectionConfigTable.dir/objects.a(mocs_compilation.cpp.obj):mocs_compilation.cpp:(.text+0x60b1): undefined reference to `NetworkInterface::qt_metacast(char const*)' CMakeFiles\test_FaultInjectionConfigTable.dir/objects.a(mocs_compilation.cpp.obj):mocs_compilation.cpp:(.text+0x60eb): undefined reference to `NetworkInterface::qt_metacall(QMetaObject::Call, int, void**)' CMakeFiles\test_FaultInjectionConfigTable.dir/objects.a(mocs_compilation.cpp.obj):mocs_compilation.cpp:(.rdata+0x3ea0): undefined reference to `NetworkInterface::staticMetaObject' CMakeFiles\test_FaultInjectionConfigTable.dir/objects.a(mocs_compilation.cpp.obj):mocs_compilation.cpp:(.rdata+0x4d60): undefined reference to `NetworkInterface::staticMetaObject' CMakeFiles\test_FaultInjectionConfigTable.dir/objects.a(test_FaultInjectionConfigTable.cpp.obj):test_FaultInjectionConfigTable.cpp:(.text+0x41e6): undefined reference to `FaultInjectionConfigTable::stopBatchExecution()' CMakeFiles\test_FaultInjectionConfigTable.dir/objects.a(test_FaultInjectionConfigTable.cpp.obj):test_FaultInjectionConfigTable.cpp:(.text+0x42a1): undefined reference to `FaultInjectionConfigTable::stopBatchExecution()' CMakeFiles\test_FaultInjectionConfigTable.dir/objects.a(test_FaultInjectionConfigTable.cpp.obj):test_FaultInjectionConfigTable.cpp:(.text+0x44bb): undefined reference to `FaultInjectionConfigTable::executeSingleFault(int)' CMakeFiles\test_FaultInjectionConfigTable.dir/objects.a(test_FaultInjectionConfigTable.cpp.obj):test_FaultInjectionConfigTable.cpp:(.text+0x4517): undefined reference to `FaultInjectionConfigTable::executeSingleFault(int)' CMakeFiles\test_FaultInjectionConfigTable.dir/objects.a(test_FaultInjectionConfigTable.cpp.obj):test_FaultInjectionConfigTable.cpp:(.text+0x4577): undefined reference to `FaultInjectionConfigTable::executeSingleFault(int)' CMakeFiles\test_FaultInjectionConfigTable.dir/objects.a(NetworkTCPManager.cpp.obj):NetworkTCPManager.cpp:(.rdata$.refptr._ZTV16NetworkInterface[.refptr._ZTV16NetworkInterface]+0x0): undefined reference to `vtable for NetworkInterface' CMakeFiles\test_FaultInjectionConfigTable.dir/objects.a(wdigetDialogrow.cpp.obj):wdigetDialogrow.cpp:(.rdata$.refptr._ZTV9DialogRow[.refptr._ZTV9DialogRow]+0x0): undefined reference to `vtable for DialogRow' CMakeFiles\test_FaultInjectionConfigTable.dir/objects.a(wdigetDialogrow.cpp.obj):wdigetDialogrow.cpp:(.rdata$.refptr._ZN9DialogRow16staticMetaObjectE[.refptr._ZN9DialogRow16staticMetaObjectE]+0x0): undefined reference to `DialogRow::staticMetaObject' collect2.exe: error: ld returned 1 exit status mingw32-make.exe[2]: *** [CMakeFiles\test_FaultInjectionConfigTable.dir\build.make:533: test_FaultInjectionConfigTable.exe] Error 1 mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:220: CMakeFiles/test_FaultInjectionConfigTable.dir/all] Error 2 mingw32-make.exe: *** [Makefile:100: all] Error 2 错误:编译失败 Press any key to continue . . .
05-28
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值