最近在学习POSIX thread编程,今天编译一个程序报如下错误:

/tmp/ccXH8mJy.o:在函数‘main’中:
deadlock.c:(.text+0xbb):对‘pthread_create’未定义的引用
deadlock.c:(.text+0x134):对‘pthread_join’未定义的引用

郁闷,百度了一下,发现在gcc编译的使用应该加上 -pthread 选项 (注意不是 -lpthread)

重新编译,顺利通过,特此纪念

 

posted on 2014-09-14 23:57  wanghetao  阅读(5099)  评论(1编辑  收藏  举报