操作系统用C语言多线程编程 对‘pthread_create’未定义的引用 报错解决办法
今天写操作系统作业
在Ubuntu Linux系统中用C语言编写多线程程序
在命令行进行编译
没通过编译
报错如下:
In file included from 4.15.c:3:0:
/usr/include/pthread.h:234:12: note: expected ‘void * (*)(void *)’ but argument is of type ‘void (*)()’
extern int pthread_create (pthread_t *__restrict __newthread,
^~~~~~~~~~~~~~
/tmp/ccQlndMt.o:在函数‘main’中:
4.15.c:(.text+0x293):对‘pthread_create’未定义的引用
4.15.c:(.text+0x2b8):对‘pthread_create’未定义的引用
4.15.c:(.text+0x2fd):对‘pthread_create’未定义的引用
4.15.c:(.text+0x322):对‘pthread_create’未定义的引用
4.15.c:(.text+0x367):对‘pthread_create’未定义的引用
/tmp/ccQlndMt.o:4.15.c:(.text+0x38c): 跟着更多未定义的参考到 pthread_create
collect2: error: ld returned 1 exit status
意思就是说代码中的pthread_create()函数未定义
- pthread_create()函数 : 是创建线程的函数。它的功能是创建线程(实际上就是确定调用该线程函数的入口点),在线程创建以后,就开始运行相关的线程函数。pthread_create的返回值 表示成功,返回0;表示出错,返回

最低0.47元/天 解锁文章
2227

被折叠的 条评论
为什么被折叠?



