Results 1 to 2 of 2
Hi
I am new to GCC.I am trying to execute simple C program to create thread using pthread_create function.when I executes this program , I am getting error as follows:
...
- 09-25-2007 #1Just Joined!
- Join Date
- Sep 2007
- Posts
- 46
getting error for pthread_create function in gcc compiler
Hi
I am new to GCC.I am trying to execute simple C program to create thread using pthread_create function.when I executes this program , I am getting error as follows:
[vineeta@vineeta vineeta]$ gcc -o thread thread.c
/tmp/ccLdGdjo.o(.text+0x2d): In function `main':
: undefined reference to `pthread_create'
/tmp/ccLdGdjo.o(.text+0x46): In function `main':
: undefined reference to `pthread_create'
/tmp/ccLdGdjo.o(.text+0x59): In function `main':
: undefined reference to `pthread_join'
/tmp/ccLdGdjo.o(.text+0x69): In function `main':
: undefined reference to `pthread_join'
collect2: ld returned 1 exit statu
Why I am getting this error and how to resolve this error???
Thanks
vineeta
- 09-25-2007 #2Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
Hi,
Welcome to the forum.
The pthread functions are not included in the standard C library. They are in libpthread, so you should add -lpthread to the command line when you link your program like:
RegardsCode:gcc -o thread thread.c -lpthread


Reply With Quote