Qt Linker Error: quot;undefined reference to vtablequot;(Qt 链接器错误:“对 vtable 的未定义引用)
本文介绍了Qt 链接器错误:“对 vtable 的未定义引用"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的标题:
#ifndef BARELYSOCKET_H
#define BARELYSOCKET_H
#include <QObject>
//! The First 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<Message> reciveMessages;
};
#endif // BARELYSOCKET_H
这是我的课:
#include <QTGui>
#include <QObject>
#include "type.h"
#include "client.h"
#include "server.h"
#include "barelysocket.h"
BarelySocket::BarelySocket()
{
//this->reciveMessages.clear();
qDebug("BarelySocket::BarelySocket()");
}
void BarelySocket::sendMessage(Message aMessage)
{
}
void BarelySocket::reciveMessage(Message aMessage)
{
}
我收到链接器错误:
undefined reference to 'vtable for BarelySocket'
- 这意味着我有一个没有实现的虚方法.但是有我的类中没有虚拟方法.
- 我注释掉了向量,认为这是原因,但是错误并没有消失.
Message是一个复杂的struct,但即使使用int不解决问题.- This implies that I have a virtual method not implemented. But there are no virtual methods in my class.
- I commented out the vector thinking that it was the cause, but the error did not go away.
- The
Messageis a complexstruct, but even usingintinstead did not fix things.
推荐答案
任何时候添加对 Q_OBJECT 宏的新调用,都需要再次运行 qmake.您所指的 vtables 问题与此直接相关.
Any time you add a new call to the Q_OBJECT macro, you need to run qmake again. The vtables issue you're referring to is directly related to that.
只要运行 qmake,假设您的代码中没有其他问题,您应该会很高兴.
Just run qmake and you should be good to go assuming there are no other issues in your code.
这篇关于Qt 链接器错误:“对 vtable 的未定义引用"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
编程基础网
本文标题为:Qt 链接器错误:“对 vtable 的未定义引用"
基础教程推荐
猜你喜欢
- 随机插入/删除的综合向量与链表基准 2022-01-01
- 提升 ASIO 流缓冲 2021-01-01
- 如何在 C++ 中正确使用命名空间? 2022-01-01
- 如何部分禁用 cmake C/C++ 自定义编译器检查 2021-01-01
- 为什么我们不能使用“虚拟继承"?在 COM 中? 2022-01-01
- 将不可复制的闭包对象传递给 std::function 参数 2021-01-01
- 与 CAS 的原子交换(使用 gcc 同步内置函数) 2022-01-01
- c++ STL设置差异 2022-01-01
- C++:获取传递给函数的多维数组的行大小 2021-01-01
- 如何更改 SysDateTimePick32 或 CDateTimeCtrl 的背景颜色? 2022-01-01
