未定义对vtable的引用... [英] undefined reference to vtable for ...
问题描述
我想编写一个Http代理,它基本上像 indianwebproxy
I am trying to write an Http proxy that basically works like indianwebproxy
所以我发射了qtcreator,但我的一个类是无法编译与臭名昭着的错误:未定义的引用vtable HttpProxyThreadBrowser
。我不知道为什么它这样做。我阅读了关于Stackoverflow的类似问题,显然是问题是未定义的虚拟方法不纯粹但我没有声明任何虚拟函数。这是我的类
So i fired up qtcreator and but one of my classes is failing to compile with the infamous error : undefined reference to vtable for HttpProxyThreadBrowser
. I can't figure out why its doing this. I read through similar questions on Stackoverflow and apparently the problem is with undefined virtual methods that are not pure But i have not declared any virtual functions. Here is my class
class HttpProxyThreadBrowser : public QThread
{
public:
HttpProxyThreadBrowser(QTcpSocket outgoingSocket,QTcpSocket browserSocket,QObject *parent = 0);
~HttpProxyThreadBrowser(){};
void run();
private:
QTcpSocket outgoingSocket;
QTcpSocket browserSocket;
};
我在 pastebin ,以免钻孔。不幸的是,我不知道为什么vtable是未定义的。请帮助。
And I define the class here in pastebin so as not to bore you. Unfortunately i cant find out why the vtable is undefined. Please assist.
httpproxythreadbrowser.cpp:5: undefined reference to `vtable for HttpProxyThreadBrowser
collect2: ld returned 1 exit status
推荐答案
您不能复制 QTcpSocket
s,因此如果您尝试通过复制而不是按地址传递它们,则可能会导致其他隐藏错误。
You can't copy QTcpSocket
s, so it may cause other cryptic errors if you try to pass them by copy rather than by address.
HttpProxyThreadBrowser(QTcpSocket * outgoingSocket,QTcpSocket * browserSocket,QObject *parent = 0);
private:
QTcpSocket* outgoingSocket;
QTcpSocket* browserSocket;
完全重新编译项目可能会有帮助,当你更改头文件时,因为qmake生成的Makefile有时会失败注意到更改。
And completely recompiling your project may help, when you change header files, because qmake generated Makefile can sometimes fail to notice the changes.
这篇关于未定义对vtable的引用...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!