On Mon, Dec 24, 2001 at 12:08:13PM -0500, Jason Costomiris wrote: > On Mon, Dec 24, 2001 at 11:25:31PM +0800, David wrote: > : I have written some multithreading code using pthread library. But when I > : compile the code, the compiling process is ok but the linking process claims > : "undefined reference" for pthread_create( ). How can I resolve this problem? > : I have included <pthread.h> and #define _REENTRANT but still doesn't work. I > : suspect the library libpthread.so is bad but having replaced that file with > : another one from Mandrake 8.0 (the file sizes are different), it > : still doesn't compile. Can anyone help me with this one? Thanks. > > You're not linking against the pthread library. You want to do something > like: > > gcc -O2 foo.c -o foo -lpthread
Actually, no LInux (and this is POORLY documented) you want to do: gcc -O2 -pthread foo.c -o foo The -pthread flag forces both reentrancy, and linking of libpthread. You may find it helpful to start subscribing to comp.programming.threads. -- ------------------------------------------------------------------------------- .---- Fred Smith / ( /__ ,__. __ __ / __ : / / / / /__) / / /__) .+' Home: [EMAIL PROTECTED] / / (__ (___ (__(_ (___ / :__ 781-438-5471 -------------------------------- Jude 1:24,25 --------------------------------- _______________________________________________ Redhat-list mailing list [EMAIL PROTECTED] https://listman.redhat.com/mailman/listinfo/redhat-list