|
下面是源码和错误提示
[root 09:20:58 develop:]#vi pthread.c
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
void task1(int *counter);
void task2(int *counter);
void cleanup(int counter1,int counter2);
int g1=0;
int g2=0;
int main(int argc, char*argv[]){
pthread_t thrd1,thrd2;
int ret;
/* creat the first thread*/
ret=pthread_creat(&thrd1,NULL,(void *)task1,(void*)&g1);
if(ret){
perror("pthread_creat:task1");
exit(EXIT_FAILURE);
}
pthread.c 1,1 顶端
"pthread.c" 57L, 972C
[root 09:20:48 develop:]# gcc pthread.c
/tmp/cc84hOAm.o: In function `main':
/tmp/cc84hOAm.o(.text+0x17): undefined reference to `pthread_creat'
/tmp/cc84hOAm.o(.text+0x57): undefined reference to `pthread_creat'
/tmp/cc84hOAm.o(.text+0x90): undefined reference to `pthread_join'
/tmp/cc84hOAm.o(.text+0xa1): undefined reference to `pthread_join'
collect2: ld returned 1 exit status |
|