现在的位置: 首页 > 综合 > 正文

编写线程函数时,链接时报错:undefined refrence to ‘pthread_create ‘

2013年09月04日 ⁄ 综合 ⁄ 共 126字 ⁄ 字号 评论关闭

这是由于pthread库不是Linux系统默认的库,连接时需要使用库libpthread.a,所以在使用pthread_create创建线程时,在编译中要加-lpthread参数:
gcc -o pthread -lpthread pthread.c

这样就行了。

抱歉!评论已关闭.