当前位置: 技术问答>linux和unix
创建线程出错
来源: 互联网 发布时间:2015-08-05
本文导语: 用gcc编译出错 [root@chuxue sem]# gcc sem.c -o sem /tmp/cckTKYXI.o(.text+0x57): In function `main': : undefined reference to `pthread_create' /tmp/cckTKYXI.o(.text+0xa6): In function `main': : undefined reference to `pthread_join' collect2: ld returned 1 ex...
用gcc编译出错
[root@chuxue sem]# gcc sem.c -o sem
/tmp/cckTKYXI.o(.text+0x57): In function `main':
: undefined reference to `pthread_create'
/tmp/cckTKYXI.o(.text+0xa6): In function `main':
: undefined reference to `pthread_join'
collect2: ld returned 1 exit status
#include
#include
#include
#include
#include
#define THREAD_NUM 2
static void * threadfunc(void *arg)
{
printf("%s", "test/n");
return;
}
int main()
{
int i;
int retval;
int *status;
int nthreadnum[THREAD_NUM];
pthread_t threadid[THREAD_NUM];
for (i=0; i
[root@chuxue sem]# gcc sem.c -o sem
/tmp/cckTKYXI.o(.text+0x57): In function `main':
: undefined reference to `pthread_create'
/tmp/cckTKYXI.o(.text+0xa6): In function `main':
: undefined reference to `pthread_join'
collect2: ld returned 1 exit status
#include
#include
#include
#include
#include
#define THREAD_NUM 2
static void * threadfunc(void *arg)
{
printf("%s", "test/n");
return;
}
int main()
{
int i;
int retval;
int *status;
int nthreadnum[THREAD_NUM];
pthread_t threadid[THREAD_NUM];
for (i=0; i