类型:转载 责任编辑:asp.net 日期:2007/05/23
热门软件下载:
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
void donothing()
{
}
int main(int argc, char *argv[])
{
pthread_t thread;
pthread_create(&thread,NULL,(void*)donothing,NULL);
}
下面是编译命令:
[groupmerit@localhost mutithread]$ gcc -c main.c
[groupmerit@localhost mutithread]$ gcc -o main main.o
main.o(.text+0x33): In function `main:
: undefined reference to `pthread_create
collect2: ld returned 1 exit status
为什么生成可执行文件会报pthread_create没定义
网友回答:
gcc -o main main.o -lpthread
要连接库。