![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Reference: WebObjects 5.4.1 Reference | iBot | UNIX and Linux RSS News | 0 | 03-11-2008 06:50 PM |
| How Can I use pthread_create ? | shvalb | High Level Programming | 5 | 03-11-2008 10:17 AM |
| about undefined reference for 'sinf' | bharat suthar | High Level Programming | 2 | 05-13-2006 05:45 PM |
| Undefined reference to Error | svh | High Level Programming | 2 | 02-10-2006 09:23 PM |
| pthread_create problem | _rocky | High Level Programming | 5 | 03-11-2005 03:38 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
undefined reference to `pthread_create'
Hi
I wanted to learn communication between threads and I used a simple example but I faced with this error while I have a sofware that uses this functions without any problem so would you please help me to know the reason thanks for your help and great favor. #include <pthread.h> #include <stdio.h> void *hello_world (void *arg) { printf ("Hello world\n"); return NULL; } int main (int argc, char *argv[]) { pthread_t hello_id; int status; status = pthread_create (&hello_id, NULL, hello_world, NULL); if (status != 0) //err_abort (status, "Create thread"); status = pthread_join (hello_id, NULL); if (status != 0) // err_abort (status, "Join thread"); return 0; } /tmp/cceZX3sJ.o(.text+0x47): In function `main': : undefined reference to `pthread_create' /tmp/cceZX3sJ.o(.text+0x60): In function `main': : undefined reference to `pthread_join' collect2: ld returned 1 exit status I had one more question I read in docs that when the parent thread terminates the child threads would be terminated too but we can change the priority of a thread so is it possible to give a thread a priority more than parent's. and can a parent terminates one of its child that has priority more or equal to its priority? thanks Best Regards. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
how did you compile this code. use the pthread library
cc -o outputfile c_code_file -lpthread
__________________
War doesnt determine who is right, it determines who is left |
|
#3
|
|||
|
|||
|
Re: undefined reference to pthread_create
I was missing the -lpthread option.
Thanks |
|||
| Google The UNIX and Linux Forums |