Ubuntu编程C多线程报错--undefined reference to pthread_create

今天做多线程编译的时候报错、
在这里插入图片描述
因为pthread不是linux下的默认的库,也就是在链接的时候,无法找到phread库中哥函数的入口地址,于是链接会失败
所以我们需要链接到相应的库

gcc main.c -o test -lpthread

这样子编译就不报错能够正常运行了

猜你喜欢

转载自blog.csdn.net/AcStudio/article/details/106846931