C threads

hi I was using threads in C and this is first time i did this in C

but when I compile (actually I think in link time) it give me a error saying

:/home/shahan/engine_driver.c:43: undefined reference to `pthread_detach'

collect2: ld returned 1 exit status

make: *** [engine] Error 1

I used <pthread.h>

and functions pthread_create and pthread_detach

it mentioned a error for both these functions

can someone tell me why? I really need help in this

Thanx

[522 byte] By [shahan_123] at [2007-11-26 10:00:22]
# 1
It would be easier to help you had you provide more information on what, where and how do you compile.It seems that you compile with gcc and it fails to link as you did not supply -lpthread to link with libpthread...regards,__Fedor.
SFV at 2007-7-7 1:29:09 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2

well yes I did compiled with gcc I used a makefile.

I included <pthread.h> in the file I used these functions.

"lpthread to link with libpthread..."

sorry...... I didnt get exactly what you said......... 'libpthread' how do I do that.

and also I'm compiling it in a FC5 machine

Message was edited by:

shahan_123

shahan_123 at 2007-7-7 1:29:09 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 3
Eh... it seems you still need to learn some unix compilers basics :)-l pthreadcauses compiler to link library (in this case it is libpthread.so - system library containing pthreads implementation).regards,__Fedor.
SFV at 2007-7-7 1:29:09 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 4
thanx buddy.......meanwhile I tried adding /lib/libpthread.so.0 to the link line in the Makefile and it workedI'll try what you said too.....thanx
shahan_123 at 2007-7-7 1:29:09 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 5
-l pthread is actually a more convenient and graceful way to link against that same libpthread.so.0Linker knows how to find system libraries and it sometimes knows it even better than you do :)regards,__Fedor.
SFV at 2007-7-7 1:29:09 > top of Java-index,Development Tools,Solaris and Linux Development Tools...