程序代马如下:
#include<stdio.h>
#include<pthread.h>
void thread (void)
{
int i;
for(i=0;i<3;i++)
{
printf("This is a pthread\n");
}
}
int main(void)
{
pthread_t id;
int i,ret;
ret=pthread_create(&id,NULL,(void *)thread,NULL);
if(ret!=0)
{
printf("Create Thread Error!\n");
// exit(0);
}
for(i=0;i<3;i++)
{
printf("This Is The Main Process!!!\n");
}
pthread_join(id,NULL);
return (0);
}
编译后的错误信息如下:
leran0222@leran0222-desktop:~/C$ gcc -o mul mul.c
/tmp/cc4uiXHG.o: In function `main':
mul.c:(.text+0x58): undefined reference to `pthread_create'
mul.c:(.text+0x9f): undefined reference to `pthread_join'
collect2: ld returned 1 exit status
leran0222@leran0222-desktop:~/C$
怎么解决这个问题???
是因为我的电脑里面去我少头文件么 ???
[问题]新手多线程编程问题
- leran0222
- 帖子: 105
- 注册时间: 2007-05-12 0:13