我有这样的代码:未定义参考在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;
}
而在编译器选项我插入-lpthread
但它说:
“未定义的引用给pthread_create”
我使用Ubuntu 10.10 ,所以我已经安装了pthread库,我找不出这个错误的原因。
向我们展示如何编译您的程序。 – cnicutar 2012-03-21 10:56:43
你是如何添加链接器选项的?在哪里?哪个版本的Code :: Blocks? – 2012-03-21 11:20:35