I created a simple program under RedHat 4.0 Linux, below, and I am
trying to link it with the libpthread.so.0 library, which is in my /lib
directory. Here is my link line:
gcc -D_REENTRANT ThreadExample.c -lpthread
Gcc keeps complaining about the pthread_t definition, even though the
pthread.h include file is under the standard /usr/include path. In
addition, gcc is unable to find the standard shared library
libpthread.so.0, which is in my /lib directory. I did a ldconfig -p and
libthread.so.0 is a symbolic link to /lib/libthread.so.0.5. I give...
Can someone please help? Here is the program:
#include <stdio.h>
#include <pthread.h>
static void* foo(void* arg);
int
main(int argc, char** argv)
{
pthread_t threads[3];
int status[3];
int i = 0;
int j = 0;
threads[i++] = pthread_create(&thread1, NULL, foo, "thread1");
threads[i++] = pthread_create(&thread2, NULL, foo, "thread2");
threads[i++] = pthread_create(&thread3, NULL, foo, "thread3");
for (j = 0; j < i; j++) {
(void) pthread_join(threads[j], &status[j]);
}
exit(0);
staticQuote:}
void*
foo(void* arg)
{
printf("Hi! I'm thread %s\n", (char*) arg);
pthread_exit(0);
return((void*) NULL);
--Quote:}
Bruce W. Bigby
http://www.frontiernet.net/~bbigby
Rochester, NY
Do for others that which you would have others do for you.
Love your enemies, and be perfect, like your Father in Heaven. Matthew
5:43-48