Results 1 to 3 of 3
Hi, I'm working on an application of C programming language. I want to build a code that uses multitasking; at the moment I'm just experimenting with examples I got from ...
- 08-11-2009 #1Just Joined!
- Join Date
- Aug 2009
- Location
- Obera, Misiones, Argentina
- Posts
- 3
Help with pthread
Hi, I'm working on an application of C programming language. I want to build a code that uses multitasking; at the moment I'm just experimenting with examples I got from books and WEBside. Many of them use pthread_create () to create a thread. I don't know why, but my compiler prints an error message that says: ".../home/investigacion/ejpthread/src/ejpthread.c:62: undefined reference to `pthread_create'". First I though it was because I didn't include the respective header (pthread.h), but even after I wrote a code line including it, the message was printed again every time I compiled my code.
Inspired in an example I found in a book of Linux programming, I wrote following code:
#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
void *child_fn (void *arg);
int main (void)
{
pthread_t tchild;
int algo;
algo = pthread_create (&tchild, NULL, &child_fn, NULL );
if (algo != 0)
perror ("Pthreads error");
pthread_join (tchild, NULL);
return 0;
}
void *child_fn (void *arg)
{
puts ("Soy un thread hijo"); //This is spanish "I'm a thread child"
return NULL;
}
Similarly occurs with function pthread_join(); compiler returns ERROR.
I'll appreciate your help. Thanks!
- 08-11-2009 #2Just Joined!
- Join Date
- Aug 2009
- Posts
- 3
- 08-11-2009 #3Just Joined!
- Join Date
- Aug 2009
- Location
- Obera, Misiones, Argentina
- Posts
- 3
ˇˇGenio!!
ˇMuchisimas gracias! A lot of thanks!!!!
That's what I needed; I have alredy tried, and it worked!


Reply With Quote
