[prog] Posix thread error

Miriam Ruiz little_miry at yahoo.es
Fri Nov 26 02:04:15 EST 2004


Hi,

Your code worked OK for me. It's not a problem of the
compiler, but the linker. When the program is
compiled, gcc tries to generate the executable code,
and cannot access the functions defined by pthread
headers in any .o file. You have to explicitly tell
gcc to link the file against libpthread with the
following command:

gcc -o example example.c -lpthread

Miry

 --- Warren Prasad <warren_pd at yahoo.com> escribió: 
> Hi,
>  
> I am getting this error while compiling 
> a posix thread program.
> I m new to posix programming and this is the 
> first program i m trying to compile using cc
> in Linux AS 2.1.
> The error i get is :
>
---------------------------------------------------------------------------------
> /tmp/ccEwkHiy.o: In function `main':
> /tmp/ccEwkHiy.o(.text+0x7c): undefined reference to
> `pthread_create'
> /tmp/ccEwkHiy.o(.text+0xb5): undefined reference to
> `pthread_join'
> collect2: ld returned 1 exit status



		
______________________________________________
Renovamos el Correo Yahoo!: ¡100 MB GRATIS!
Nuevos servicios, más seguridad
http://correo.yahoo.es


More information about the Programming mailing list