简体   繁体   中英

while compiling thread program on linux machine it gives “undefined reference ” error

嗨,我已经在线程中编写了一个简单的程序来创建10个线程并正常执行它们,但是当我在linux机器上编译代码时,它给出了以下错误。. * / tmp / cc4swqyK.o:在main': threadcreate1.c:(.text+0x40): undefined reference to函数中main': threadcreate1.c:(.text+0x40): undefined reference to pthread_create的main': threadcreate1.c:(.text+0x40): undefined reference to threadcreate1.c :(。text + 0x78):对pthread_join的未定义引用collect2:ld返回1退出状态*

Are you compiling it as 'gcc -lpthread fileName.c'

You will have to include the header file pthread.h

#include <pthread.h>

and when compiling, specify the library to link with using ' -l 'option of gcc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM