- 论坛徽章:
- 0
|
linux刚开始学习,还请大家多多关照
下面是一个很短而且简单的程序
#include <stdio.h>
#include <pthread.h>
void myfirstthread(void){
printf("this is my thread.\n");
}
int mian(void){
pthread_t id;
int i,ret;
ret=pthread_create(&id,NULL,(void *)myfirstthread,NULL);
pthread_join(id,NULL);
return (0);
}
程序报错:undeifined reference to 'pthread_create'
undefined reference to 'pthread_join'
在/usr/include文件夹下面我找到了pthread.h的文件,
发现里面有pthread_t的定义,但是只有pthread_create,pthread_join的外部调用声明
但是我的参考书上除了讲到要包含pthread.h头文件外,并没有提及其他.h或.lib的文件啊
我应该如何改正才能使线程编程正确执行?
[ 本帖最后由 huazhuzi 于 2007-5-3 14:16 编辑 ] |
|