This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
gcc, pthread on SunOS5.7
- To: <gcc at gcc dot gnu dot org>, <libc-alpha at sourceware dot cygnus dot com>, <linux-gcc at vger dot kernel dot org>
- Subject: gcc, pthread on SunOS5.7
- From: "Anand Padhye" <anand dot padhye at wipro dot com>
- Date: Mon, 30 Jul 2001 15:33:12 +0530
- Disposition-Notification-To: "Anand Padhye" <anand.padhye@wipro.com>
Hello!
I am using simple threads in my code (using gcc on SunOS 5.7). Works fine if
linked using -lpthread. If I do not use -lpthread, it still gives no error,
creates a.out but does not run properly. Whay does gcc not give linking
error on SunOS5.7 if -lpthread is not given ? It gives a linking error on
Linux if -lpthread is not given.
Can someone help ?
Here is the code ---
#include <stdio.h>
#include <string.h>
#include <pthread.h>
int f1()
{
int x1 = 0;
while (1)
{
x1++;
printf("f1() - x1 = %d\n", x1);
sleep(3);
}
}
int f2()
{
int x2 = 0;
while (1)
{
x2++;
printf("\t\t\t f2() - x2 = %d\n", x2);
sleep(3);
}
}
int main()
{
pthread_t t1, t2;
pthread_create(&t1, NULL, (void*)f1, NULL);
pthread_create(&t2, NULL, (void*)f2, NULL);
while(1)
{
printf("main() - still running\n");
sleep(5);
}
return 0;
}
Regards,
Anand
The Information contained and transmitted by this E-MAIL is proprietary to
Wipro Limited and is intended for use only by the individual or entity to which
it is addressed, and may contain information that is privileged, confidential or
exempt from disclosure under applicable law. If this is a forwarded message,
the content of this E-MAIL may not have been sent with the authority of the
Company. If you are not the intended recipient, an agent of the intended
recipient or a person responsible for delivering the information to the named
recipient, you are notified that any use, distribution, transmission, printing,
copying or dissemination of this information in any way or in any manner is
strictly prohibited. If you have received this communication in error, please
delete this mail & notify us immediately at mailadmin@wipro.com