The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 01-06-2006
Registered User
 

Join Date: Jan 2006
Posts: 5
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.
Reply With Quote
Forum Sponsor
  #2  
Old 01-08-2006
linuxpenguin's Avatar
Registered User
 

Join Date: May 2002
Location: India
Posts: 295
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
Reply With Quote
  #3  
Old 01-28-2008
Registered User
 

Join Date: Jan 2008
Posts: 1
Re: undefined reference to pthread_create

I was missing the -lpthread option.
Thanks
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:11 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0