2
rated 0 times
[
2]
[
0]
/ answers: 1 / hits: 3722
/ 3 Years ago, sun, september 26, 2021, 9:16:35
I have a small a program that should start a 2nd Thread. the problem is that, when try to make an executable file of this program using make. I get :
engine@ubuntu:~/Desktop/Lecture$ make thread
cc thread.c -o thread
thread.c: In function ‘main’:
thread.c:10:2: error: unknown type name ‘pthread’ .............
here is my code :
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <errno.h>
void *func(void*);
int main(){
pthread tid;
if (pthread_create(&tid,NULL,fun,NULL)!= 0 ){
printf("error by _ pthread
");
}
printf ( "thread output1
");
sleep(1);
return EXIT_SUCCESS;
}
void *fun(void* data){
printf("thread output2
")
}
I don't think that program is wrong, it maybe the way I'm running the make command ?
any Idea why do I get this.
thanks in advance for your help
More From » c