大家帮小弟我看看,为什么pthread_create没有定义,在gcc运行时

大家帮我看看,为什么pthread_create没有定义,在gcc运行时
#include <stdio.h>
#include <pthread.h>
#include <string.h>
void* task(void* p){
   int i;
   for(i = 0;i <30;i++)printf("task:%d\n",i);
}
int main () {
   pthread_t id;
   int res = pthread_create(&id,0,task,0);
   if(res)printf("%s\n",strerror(res));
   int i;
   for(i = 0;i < 30;i++)printf("main:%d\n",i);
   pthread_t id2 = pthread_self();
   printf("%u %u\n",id ,id2);
   sleep(1);
}
------解决方案--------------------
gcc编译时添加链接选项-lpthread可以解决
------解决方案--------------------
gcc -Wall -c "001.c" 
001.c: In function ‘main’:
001.c:21:4: warning: implicit declaration of function ‘sleep’ [-Wimplicit-function-declaration]
    sleep(1);
    ^
001.c: In function ‘task’:
001.c:10:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
编译成功结束。