[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Multithreading



Hi

I think this problem is related to a qt package that is shipping with debian 
potato, not qt i general. If not, my apogees for posting to the wrong list.

I'm trying to compile an application that is using QThread class (in this 
case, an example program from the qt doc, see below), but I is getting 
linking errors (see below). When compiling I'm adding the flag 
"QT_THREAD_SUPPORT" and exchanging "-lqt" with "-lqt-mt", everything by the 
book, but it don't work. It is saying that the qthread class is missing.

So how can I now say that I think this is a package problem in debian? Well, 
I did my own compiling of the qt library (by hand, "./configure", "make all" 
etc) and added "-L <path to my qt dir>/lib" to the compiling flags and now 
the compiling is working. When comparing the size between qt and qt-mt, my 
version is about 10k in difference and the qt-package isn't even 100 byte.

I'm using potato, qt 2.2.4, kde 2.1 beta from kde.tydc.com.

I hope someone can help me with my problem.
	Martin



Compile line : "gcc thread_test.cpp -I/usr/include/qt \lqt-mt"
Program :

#define QT_THREAD_SUPPORT
#include <qthread.h>

class MyThread : public QThread
{
public:
    virtual void run();
};

void MyThread::run()
{
    for(int count=0;count<20;count++)
    {
	sleep(1);
	qDebug("Ping!");
    }
}

int main()
{
    MyThread a;
    MyThread b;

    a.start();
    b.start();

    a.wait();
    b.wait();
}

Compile errors:
/tmp/ccMkdElz.o: In function `MyThread::run(void)':
/tmp/ccMkdElz.o(.text+0x26): undefined reference to `QThread::sleep(unsigned 
long)'
/tmp/ccMkdElz.o: In function `main':
/tmp/ccMkdElz.o(.text+0x74): undefined reference to `QThread::start(void)'
/tmp/ccMkdElz.o(.text+0x83): undefined reference to `QThread::start(void)'
/tmp/ccMkdElz.o(.text+0x94): undefined reference to `QThread::wait(unsigned 
long)'
/tmp/ccMkdElz.o(.text+0xa5): undefined reference to `QThread::wait(unsigned 
long)'
/tmp/ccMkdElz.o: In function `MyThread type_info function':
/tmp/ccMkdElz.o(.gnu.linkonce.t.__tf8MyThread+0x10): undefined reference to 
`QThread type_info function'
/tmp/ccMkdElz.o(.gnu.linkonce.t.__tf8MyThread+0x1a): undefined reference to 
`QThread type_info node'
/tmp/ccMkdElz.o: In function `MyThread::~MyThread(void)':
/tmp/ccMkdElz.o(.gnu.linkonce.t._._8MyThread+0x14): undefined reference to 
`QThread::~QThread(void)'
/tmp/ccMkdElz.o: In function `MyThread::MyThread(void)':
/tmp/ccMkdElz.o(.MyThread::gnu.linkonce.t.(void)+0xf): undefined reference to 
`QThread::QThread(void)'
/tmp/ccMkdElz.o(.MyThread::gnu.linkonce.t.(void)+0x37): undefined reference 
to `QThread::~QThread(void)'
collect2: ld returned 1 exit status



Reply to: