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

来源:互联网 发布:自动加微信群软件 编辑:程序博客网 时间:2024/06/12 01:08

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

这样就行了。

原创粉丝点击