Bonjour, je suis débutant en programmation système sous unix, et j'essaye de me familiariser avec les threads, cependant j'ai toujours un problème à la compilation:
voici mon code (pour essayer):
include <pthread.h>
#include<stdio.h>
#include<stdlib.h>
void *My_process(void *arg)
{
int dI;
for(dI=0;dI<5;dI++)
{
printf("\nThread %s: %d\n",(char*)arg,dI);
sleep(1);
}
pthread_exit(0);
}
main(int ac,char **av)
{
pthread_t th1,th2;
void * ret;
if(pthread_create(&th1,NULL,My_process,"1")<0)
{
printf("\nThread error");
exit(1);
}
if(pthread_create(&th2,NULL,My_process,"1")<0)
{
printf("\nThread error");
exit(1);
}
(void)pthread_join(th1,&ret);
(void)pthread_join(th2,&ret);
}
j'ai un message : undefined reference to pthread_create.
J'utilise mandrake 9.1, comment puis je faire pour faire fonctionner ce petit programme?
Merci d'avance