PDA

View Full Version : Strange errors



prykHetQuo
14th March 2009, 16:33
OS: Ubuntu Linux 8.10 x64

QT version: 4.4.3

The code:



#include <QApplication>
#include <QHttp>
#include <QString>

#include <iostream>

class Test: public QObject
{
Q_OBJECT

QHttp objQHttp;

public:

Test(QObject *parent= 0): QObject(parent), objQHttp("ftp.otenet.gr")
{
connect(&objQHttp, SIGNAL(dataReadProgress(int, int)), this, SLOT(DisplayProgress(int, int)));

objQHttp.get("/linux/ubuntu-releases/intrepid/ubuntu-8.10-desktop-amd64.iso");
}


private slots:
void DisplayProgress(int done, int total)
{
std::cout<< done<< " of "<< total<< " has been downloaded so far\n";
}
};


int main(int argc, char *argv[])
{
QApplication app(argc, argv);

Test obj(0);

app.exec();

return 0;
}




with QT+= network added in the .pro file, produces:



john@ubuntu:~/Projects/qt/test$ make
g++ -Wl,--no-undefined -o test main.o -L/usr/lib -lQtGui -lQtNetwork -lQtCore -lpthread
main.o: In function `main':
main.cpp:(.text+0x77): undefined reference to `vtable for Test'
main.cpp:(.text+0x117): undefined reference to `vtable for Test'
main.o: In function `Test::~Test()':
main.cpp:(.text._ZN4TestD1Ev[Test::~Test()]+0x14): undefined reference to `vtable for Test'
collect2: ld returned 1 exit status
make: *** [test] Error 1


How can this be fixed?

ComaWhite
14th March 2009, 19:00
add this to it



#include "test.moc"


Add it before the main() and after the Test class. You should seperate this.

Lykurg
14th March 2009, 19:13
...or better use separate files. One for the main function, one test.cpp and one text.h. This would I prefer.