This is the mail archive of the
mailing list for the GCC project.
RE: HELP~~! Tell me the CORRECT method to use gcc/g++ whith pthread, please
- From: "Rupert Wood" <me at rupey dot net>
- To: "'PeterPan'" <peterpan at chinaren-inc dot com>
- Cc: <gcc-help at gcc dot gnu dot org>
- Date: Wed, 19 Dec 2001 07:43:56 -0000
- Subject: RE: HELP~~! Tell me the CORRECT method to use gcc/g++ whith pthread, please
> what is the real meaning of --enable-threads=LIB ?
It specifies which threading model should be used by the threading
abstraction in <bits/gthr.h>. This is used by two of GCC's support
libraries. I'm not sure if it's intended for general use - I don't think
it's documented in the manual.
> SHOULD I DEFINE ANY FLAGS MYSELF IN ORDER TO USE THREADS CORRECTLY,
> IF I SHOULD, WHICH FLAGS ?? HOW ??
I think so. If you're using pthreads, you'll need to define '_REENTRANT'
to get thread safe versions of errno, etc., and presumably '_PTHREADS'
(although I haven't seen that one before). You'll also need to link
against libpthread or you'll get the stubbed out versions from the
Solaris libc that just return failure.
To do this, e.g.
gcc -D_PTHREADS -D_REENTRANT source.c -lpthread
See 'man threads' on Solaris. The Sun compiler switch '-mt', however, is
not supported by GCC: this causes the Sun compiler to define
'_REENTRANT' and enable (AFAIK) Solaris threads support.
> On a solaris x86, using POSIX pthreads (not Solaris threads),
> which LIB should I use? "--enable-threads=solaris"
> or "--enable-threads=posix", and any extra FLAGS??
For pthreads, "--enable-threads=posix" or "--enable-threads=pthreads".
No extra flags at compiler configure/build.
> thirdly, how about AIX ?? I have written a email ( using my old
> email address email@example.com) to say can't configure
> correct thread mode on AIX, u guys simply ignored me.
It happens. The serious developers don't have time to answer questions
on this list so it's left to we less knowledgeable few. I've never
If you're really stuck you could try writing to the development list,
firstname.lastname@example.org. Keep it short and to the point and mention that you've
had no luck on gcc-help. You might still get ignored, though.
Hope this helps,