linux:编译多线程报错---undefined reference to ‘pthread_create’

问题描述:

    在gcc mutithread.c 编译.c文件以后报如下错误:

错误原因:

    pthread不是Linux下的默认的库,也就是在链接的时候,无法找到phread库中函数的入口地址,于是链接会失败,无法识别。

解决方法:

    在编译中要加 -lpthread 选项

    gcc mutithread.c -o thread -lpthread

猜你喜欢

转载自blog.csdn.net/m0_37051593/article/details/80718905