pthread.h引用时编译c代码要link该库

*错误的编译:
[root@localhost c_test]# gcc exam_26.c -o exam_26.c
/tmp/cc9l1gOq.o:在函数‘main’中:
exam_26.c:(.text+0x4f):对‘pthread_create’未定义的引用
exam_26.c:(.text+0xbf):对‘pthread_join’未定义的引用

正确的编译:
gcc exam_26.c -lpthread -o exam_26

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容