Steve Clamage <stephen.clam...@sun.com> wrote:

> A customer had a small program using pthreads that crashed pretty much at 
> startup. After verifying the crash on my system, I noticed that the customer 
> had not linked the program with libpthread. Adding -lpthread to the linking 
> command fixed the problem.
>
> If a program does not link a needed library, shouldn't it fail at link time? 
> As it is, the program links and loads, but crashes mysteriously. Why is this 
> a good idea? Why are there entry points in /lib/libc.so.1 for pthread 
> functions, but not the pthread functionality?

This is true since 1992.....

The libc entries are dummy functions to allow libc to include functions that 
include pthread support that is working automatically when you link against 
-lptread.


A correct autoconf test looks this way:

AC_CHECK_LIB(pthread, pthread_create, lib_pthread="-lpthread", 
  [AC_CHECK_LIB(c, pthread_create, lib_pthread="")]) 

Note: first check -lpthread and then check -lc

Jörg

-- 
 EMail:jo...@schily.isdn.cs.tu-berlin.de (home) Jörg Schilling D-13353 Berlin
       j...@cs.tu-berlin.de                (uni)  
       joerg.schill...@fokus.fraunhofer.de (work) Blog: 
http://schily.blogspot.com/
 URL:  http://cdrecord.berlios.de/private/ ftp://ftp.berlios.de/pub/schily
_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to