[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: autoconf, sendmail, and pthreads

From: Bob Friesenhahn
Subject: Re: autoconf, sendmail, and pthreads
Date: Thu, 21 Dec 2000 10:40:10 -0600 (CST)

On Thu, 21 Dec 2000 address@hidden wrote:
>    -pthread -- is for gcc

Support for -pthread in gcc is non-standard.  It is not supported by
the standard GNU compiler (e.g. 2.95.2) when configured and compiled
from distributed sources.

The portable way to support POSIX threads for SunOS 5.6 and later is
to add -D_REENTRANT to the compilation defines, and -lpthread to the
libraries. Use of -lposix4 is optional, and is not necessarily
required in order to use -lpthread.  See the threads(3t) manual page.

> 1. I can test this on Solaris 2.6 with Sun CC 4.2
> 2. I can tell 3 cases:
>    1. Solaris and GCC  -- then we must:
>       1. define _POSIX_THREAD_SEMANTIC, 
>         if gcc was configurated with --enable-threads

I am not aware of the purpose of this define, and don't see it in the
Solaris 2.6 headers.  Adding -lpthreads to the link line is sufficient
to obtain POSIX thread semantics.

>       2. additionally add -pthread for gcc-2.7.2 from sunfreesof ;)
>         ( I may be wrong, becouse I was never use gcc-2.7.2 on Sun
>           Solaris)
>    2. Solaris and Sun C++ workshop
>       1. add -mt flag to CFLAGS and CXXFLAGS 
>       2. define _POSIX_THREAD_SEMANTICS 

Adding -lpthread is sufficient to obtain POSIX thread semantics.  I
assume that this extra define (which won't work with SunOS 5.6) is
trying to overcome the fact that -mt only adds -lthread (for UI

It is worth noting that you can successfully (and reliably) use the
Sun Workshop compiler with threads (while not using -mt), by following
the same steps I described above for gcc.  This allows both gcc and
Sun Workshop to be treated the same.

Bob Friesenhahn

reply via email to

[Prev in Thread] Current Thread [Next in Thread]