【Linux问题解决】操作系统用C语言多线程编程 对‘pthread_create’未定义的引用 报错解决办法

操作系统用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;表示出错,返回
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值