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

2020-05-16  本文已影响0人  janey001_zhao

*错误的编译:
[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

上一篇 下一篇

猜你喜欢

热点阅读