Probleme de creation des threads
Salut tous le monde, mon probleme c'est que mon code de création de thread ne s’exécute pas malgré qu'il y a pas d'erreurs.
voici mon code (c'est trés simple):oops: :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| #include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<pthread.h>
void *thread_1(void *arg)
{
printf("Nous sommes dans le thread.\n");
(void) arg;
pthread_exit(NULL);
}
int main(void)
{
pthread_t thread1;
printf("Avant la création du thread.\n");
if(pthread_create(&thread1, NULL, thread_1, NULL) == -1)
{
perror("pthread_create");
return EXIT_FAILURE;
}
printf("Après la création du thread.\n");
return EXIT_SUCCESS;
} |
voici la commande que j'ai entré:
l'erreur donné dans la ligne des commandes est: gcc -lpthread thread.c -o monProgramme
Code:
1 2 3
| /tmp/ccalHXWm.o: In function `main':
thread.c:(.text+0x53): undefined reference to `pthread_create'
collect2: ld a retourné 1 code d'état d'exécution |
SVP votre aide:cry: