ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am trying to write some program in linux using kde and QT. I am going to add some threading functions into the program but is having problem with it. What lib should i use for the threads? Saw that glib has some threading functions to use but my kde does not recognise the glib. How do i get the kde to link to glib?
BTW this is a super newbie who needs to hand in the program in a week time!!!
/*
Don't forget this; you may have to specify full path or pass directory to
gcc via -I option
*/
#include <pthread.h>
/*
Our thread function
*/
void* my_thread_func(void*){
//Whatever it does
.
.
pthread_exit(NULL);//Or some void* if required
}
/*
Thread function(s) is/are created here
*/
void my_thread_creation_func(void* data){
.
.
pthread_t thrd_handle;
int tcr_res;
//Start the thread;you may pass pthread_attr instead of NULL
tcr_res=pthread_create(&thrd_handle,NULL,my_thread_func,(void*)data);
.
.
}
BTW if the thread function is a class method, don't forget that it must
be static.
thanks for all the replies ... i have used the Qthread class to implement my threads. but after i write my own cpp file which inherit the qthread and write the run(), i have compile error which says "multiple definition of run() and ClientThread". Anyone has any idea what happen and how to solve it?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.