tôi có mã này:tham khảo Không xác định để pthread_create
#include <stdio.h>
#include <pthread.h>
void* cuoco(void* arg)
{
fprintf(stderr,"Inizio codice cuoco\n");
fprintf(stderr,"Fine codice cuoco\n");
return NULL;
}
void* cameriere(void* arg)
{
fprintf(stderr,"Inizio codice cameriere\n");
fprintf(stderr,"Fine codice cameriere\n");
return NULL;
}
void* cliente(void* arg)
{
fprintf(stderr,"Inizio codice cliente\n");
fprintf(stderr,"Fine codice cliente\n");
return NULL;
}
int main(int argc, char* argv[])
{
void* (*routine)(void*);
routine=cuoco;
pthread_t thread_cuoco,thread_cameriere,thread_cliente;
pthread_create(&thread_cuoco,NULL,routine,NULL);
return 0;
}
Và trong các tùy chọn trình biên dịch tôi chèn -lpthread
Nhưng nó nói:
"tài liệu tham khảo Không xác định để pthread_create"
tôi sử dụng ubuntu 10.10 , vì vậy tôi đã cài đặt thư viện pthread, tôi không thể tìm ra lý do của lỗi này.
Cho chúng tôi biết cách bạn biên dịch chương trình của mình. – cnicutar
Bạn đã thêm tùy chọn trình liên kết và ở đâu? Phiên bản nào của Code :: Blocks? –