mam problem ze skompilowaniem programu, który tworzy wątki.
Tu jest mój kod:
Kod: Zaznacz cały
#include<stdio.h>
#include<pthread.h>
//using namespace std;
int k=0;
void *
produce(void *arg){
for(;;){
if( k>=10)
return NULL;
//cout << "k: " << k << endl;
printf("k: %\n", k);
*((int *) arg) += 1;
}
}
int main(){
//cout <<"Hello World" << endl;
printf("Hello world\n");
//int k=0;
int i, nthreads, count[10];
pthread_t tid_produce[10], tid_consume;
nthreads=10;
Set_concurrency(nthreads);
for(i=0; i<nthreads; i++){
count[i]=0;
Pthread_create(&tid_produce[i], NULL, produce, &count[i]);
}
return 0;
}
Program był przerabiany z C++ jak widać, ale dałem mu rozszerzenie .c więc raczej nie to stanowi problem...us@us-laptop:~$ cc -o watek_c -lpthread watek.c
/tmp/ccuxk4wM.o: In function `main':
watek.c:(.text+0x6e): undefined reference to `Set_concurrency'
watek.c:(.text+0xb6): undefined reference to `Pthread_create'
collect2: ld returned 1 exit status