当前位置: 技术问答>linux和unix
linux下开发多线程程序,老是报这个错,怎么了?
来源: 互联网 发布时间:2015-11-16
本文导语: [root@localhost /]# gcc pthread.c /tmp/cck3yHMe.o(.text+0x2af): In function `main': : undefined reference to `pthread_create' /tmp/cck3yHMe.o(.text+0x2c4): In function `main': : undefined reference to `pthread_create' /tmp/cck3yHMe.o(.text+0x2d6): In function `main...
[root@localhost /]# gcc pthread.c
/tmp/cck3yHMe.o(.text+0x2af): In function `main':
: undefined reference to `pthread_create'
/tmp/cck3yHMe.o(.text+0x2c4): In function `main':
: undefined reference to `pthread_create'
/tmp/cck3yHMe.o(.text+0x2d6): In function `main':
: undefined reference to `pthread_join'
/tmp/cck3yHMe.o(.text+0x2e8): In function `main':
: undefined reference to `pthread_join'
collect2: ld returned 1 exit status
我的pthread.c文件中#include 了 pthread.h头文件啊,
而且我查看了这个头文件,里面定久了pthread_create和pthread_join这两个函数呀.为什么还报错.
/tmp/cck3yHMe.o(.text+0x2af): In function `main':
: undefined reference to `pthread_create'
/tmp/cck3yHMe.o(.text+0x2c4): In function `main':
: undefined reference to `pthread_create'
/tmp/cck3yHMe.o(.text+0x2d6): In function `main':
: undefined reference to `pthread_join'
/tmp/cck3yHMe.o(.text+0x2e8): In function `main':
: undefined reference to `pthread_join'
collect2: ld returned 1 exit status
我的pthread.c文件中#include 了 pthread.h头文件啊,
而且我查看了这个头文件,里面定久了pthread_create和pthread_join这两个函数呀.为什么还报错.
|
gcc pthread.c -lpthread试试看
|
没有使用线程库,解决方法如楼上所说
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。