undefinded reference to 'pthread_create'问题

pthread_create()是linux上,创建新线程的调用,按照info给出的例子使用,编译时,会出现这个错误提示。这实际是一个链接错误。原因是,该函数实现在libpthread.so或者libpthread_nonshare.a中(在64 bit OS上,这两个库在/usr/lib64目录中),但是这两个库都不是linux的默认库,编译时,需要加上-lpthread参数。
例如: g++ xxx.c -o xxx -lpthread
如果使用了类似eclipse之类的IDE工具,可以在项目属性中设置。
posted @ 2011-03-04 15:47  fre2technic  阅读(345)  评论(0编辑  收藏  举报