This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: HELP~~! Tell me the CORRECT method to use gcc/g++ whith pthread, please


PeterPan wrote:

> 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 peterpan@chinaren-inc.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
touched AIX.

If you're really stuck you could try writing to the development list,
gcc@gcc.gnu.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,
Rup.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]