当前位置: 技术问答>linux和unix
有谁能帮我看看这个关于线程编译的问题,他总是报告说undefined reference
来源: 互联网 发布时间:2014-11-19
本文导语: gcc -o test mytest.c /tmp/cctg4vof.o: In function 'main': /tmp/cctg4vof.o(.text+0x357): undefined reference to 'pthread_create' /tmp/cctg4vof.o(.text+0x42d): undefined reference to 'pthread_join' collect2: ld returned 1 exit status | 试试用 gc...
gcc -o test mytest.c
/tmp/cctg4vof.o: In function 'main':
/tmp/cctg4vof.o(.text+0x357): undefined reference to 'pthread_create'
/tmp/cctg4vof.o(.text+0x42d): undefined reference to 'pthread_join'
collect2: ld returned 1 exit status
/tmp/cctg4vof.o: In function 'main':
/tmp/cctg4vof.o(.text+0x357): undefined reference to 'pthread_create'
/tmp/cctg4vof.o(.text+0x42d): undefined reference to 'pthread_join'
collect2: ld returned 1 exit status
|
试试用 gcc -o test mytest.c -lpthread
|
楼上对的。线程库没有联。
|
把pthread.h文件放到main程序之前,而且最好在include...的下一行再加上定义
,如:
void pathread(参数);
,如:
void pathread(参数);