本文介紹了Qt 鏈接器錯(cuò)誤:“對(duì) vtable 的未定義引用"的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
這是我的標(biāo)題:
#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)
{
}
我收到鏈接器錯(cuò)誤:
undefined reference to 'vtable for BarelySocket'
- 這意味著我有一個(gè)沒(méi)有實(shí)現(xiàn)的虛方法.但是有我的類(lèi)中沒(méi)有虛擬方法.
- 我注釋掉了向量,認(rèn)為這是原因,但是錯(cuò)誤并沒(méi)有消失.
Message
是一個(gè)復(fù)雜的struct
,但即使使用int
不解決問(wèn)題.- 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
Message
is a complexstruct
, but even usingint
instead did not fix things.
推薦答案
任何時(shí)候添加對(duì) Q_OBJECT 宏的新調(diào)用,都需要再次運(yùn)行 qmake.您所指的 vtables 問(wèn)題與此直接相關(guān).
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.
只要運(yùn)行 qmake,假設(shè)您的代碼中沒(méi)有其他問(wèn)題,您應(yīng)該會(huì)很高興.
Just run qmake and you should be good to go assuming there are no other issues in your code.
這篇關(guān)于Qt 鏈接器錯(cuò)誤:“對(duì) vtable 的未定義引用"的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!