求达人帮忙:小弟我用的环境是ubuntu 12.04 ,shell选的是/bin/bash,在进行线程编程时,提示说pthread_create()这个函数没有定义

求达人帮忙:我用的环境是ubuntu 12.04 ,shell选的是/bin/bash,在进行线程编程时,提示说pthread_create()这个函数没有定义
求达人帮忙:我用的环境是ubuntu 12.04 ,shell选的是/bin/bash,在进行线程编程时,提示说pthread_create()这个函数没有定义,下面这个程序是unix环境高级编程程序清单11-1,打印线程id,我把参数_SC_THREADS作为常数调用sysconf()函数返回值是:200809,说明系统是支持线程编程的啊,我也到/usr/include目录下找到了头文件 pthread.h,而且头文件里面有函数pthread_create()的声明,但是我编译下面的函数时,提示说:undefined reference to ‘pthread_create',不知道怎么回事,求高手??????
#include "apue.h"
#include <pthread.h>

pthread_t ntid;
void printids(const char *s)
{
pid_t pid;
pthread_t tid;

pid=getpid();
tid=pthread_self();
printf("%s pid %u tid (0x%x)\n",s,(unsigned int)pid,(unsigned int)tid,(unsigned int)tid);
}
void *thr_fn(void *arg){
printids("new thread:");
return ((void *)0);
}
int main(void)
{
int err;
err=pthread_create(&ntid,NULL,thr_fn,NULL);
if(err!=0)
err_quit("can not create thread:%s\n",strerror(err));
printids("main thread:");
sleep(1);
exit(0);
}


------解决方案--------------------
引用:
求达人帮忙:我用的环境是ubuntu 12.04 ,shell选的是/bin/bash,在进行线程编程时,提示说pthread_create()这个函数没有定义,下面这个程序是unix环境高级编程程序清单11-1,打印线程id,我把参数_SC_THREADS作为常数调用sysconf()函数返回值是:200809,说明系统是支持线程编程的啊,我也到/usr/include……


线程库是第三方的 加参数 gcc -lpthread