multithread

Discussion in 'C++' started by Philipp Kraus, Aug 24, 2010.

  1. Hi,

    I hope, that my topic is not off-topic.
    I try to compile with g++ 4.0.1 a multithreaded library. On MS Visual
    Studio I must set the crt-libs for multithreaded.
    Do I need this for g++? Is there a falg (linker / compiler) for using
    multithread?

    Thanks

    Phil
     
    Philipp Kraus, Aug 24, 2010
    #1
    1. Advertising

  2. Hi,

    Philipp Kraus wrote:
    > I hope, that my topic is not off-topic.
    > I try to compile with g++ 4.0.1 a multithreaded library. On MS Visual
    > Studio I must set the crt-libs for multithreaded.
    > Do I need this for g++? Is there a falg (linker / compiler) for using
    > multithread?


    this is platform dependent, even with gcc. So there is no general answer.

    You have to check informations about your platform or ask in a platform
    related group.


    Marcel
     
    Marcel Müller, Aug 24, 2010
    #2
    1. Advertising

  3. Am 24.08.2010 11:32, schrieb Philipp Kraus:
    > Hi,
    >
    > I hope, that my topic is not off-topic.
    > I try to compile with g++ 4.0.1 a multithreaded library. On MS Visual
    > Studio I must set the crt-libs for multithreaded.
    > Do I need this for g++? Is there a falg (linker / compiler) for using
    > multithread?
    >
    > Thanks
    >
    > Phil
    >


    On most Unixes (including Mac OSX) you have to use -pthread für
    compiling and linking.

    Lars
     
    Lars Tetzlaff, Aug 24, 2010
    #3
  4. On 8/24/2010 5:32 AM, Philipp Kraus wrote:
    > I hope, that my topic is not off-topic.
    > I try to compile with g++ 4.0.1 a multithreaded library. On MS Visual
    > Studio I must set the crt-libs for multithreaded.
    > Do I need this for g++? Is there a falg (linker / compiler) for using
    > multithread?


    Just to let you know, there is a hierarchy of newsgroups, whose name
    stars with 'gnu.', for questions specific to those products. There is,
    AFAIK, a subhierarchy 'gnu.g++.*', but I don't follow it closely to know
    how useful (or useless) it might be.

    And, generally speaking, questions on specific compilers, their options,
    their libraries, command line format, etc., *are* off-topic.

    V
    --
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Aug 24, 2010
    #4
  5. Philipp Kraus

    Jorgen Grahn Guest

    On Tue, 2010-08-24, Lars Tetzlaff wrote:
    > Am 24.08.2010 11:32, schrieb Philipp Kraus:
    >> Hi,
    >>
    >> I hope, that my topic is not off-topic.
    >> I try to compile with g++ 4.0.1 a multithreaded library. On MS Visual
    >> Studio I must set the crt-libs for multithreaded.
    >> Do I need this for g++? Is there a falg (linker / compiler) for using
    >> multithread?

    >
    > On most Unixes (including Mac OSX) you have to use -pthread für
    > compiling and linking.


    I don't know MacOS but I know the others, and I believe you're wrong.
    You have to link with the Pthreads library (-lpthread) to use the
    Pthreads functions, but there's nothing remarkable about that.

    There was in the distant past a #define _REENTRANT which prepared the
    C standard library for multithreaded use ... unsure which systems need
    it today, but that's easy to google for.

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
     
    Jorgen Grahn, Aug 25, 2010
    #5
  6. Am 25.08.2010 09:38, schrieb Jorgen Grahn:
    > On Tue, 2010-08-24, Lars Tetzlaff wrote:
    >> Am 24.08.2010 11:32, schrieb Philipp Kraus:
    >>> Hi,
    >>>
    >>> I hope, that my topic is not off-topic.
    >>> I try to compile with g++ 4.0.1 a multithreaded library. On MS Visual
    >>> Studio I must set the crt-libs for multithreaded.
    >>> Do I need this for g++? Is there a falg (linker / compiler) for using
    >>> multithread?

    >>
    >> On most Unixes (including Mac OSX) you have to use -pthread für
    >> compiling and linking.

    >
    > I don't know MacOS but I know the others, and I believe you're wrong.
    > You have to link with the Pthreads library (-lpthread) to use the
    > Pthreads functions, but there's nothing remarkable about that.
    >
    > There was in the distant past a #define _REENTRANT which prepared the
    > C standard library for multithreaded use ... unsure which systems need
    > it today, but that's easy to google for.
    >
    > /Jorgen
    >


    No, -pthread implies -lpthread but also switches the compiler to
    threaded mode (i.e. errno is thread local).

    From info g++:

    `-pthread'
    Adds support for multithreading with the "pthreads" library. This
    option sets flags for both the preprocessor and linker.



    Lars
     
    Lars Tetzlaff, Aug 25, 2010
    #6
  7. Philipp Kraus

    Jorgen Grahn Guest

    On Wed, 2010-08-25, Lars Tetzlaff wrote:
    > Am 25.08.2010 09:38, schrieb Jorgen Grahn:
    >> On Tue, 2010-08-24, Lars Tetzlaff wrote:
    >>> Am 24.08.2010 11:32, schrieb Philipp Kraus:
    >>>> Hi,
    >>>>
    >>>> I hope, that my topic is not off-topic.
    >>>> I try to compile with g++ 4.0.1 a multithreaded library. On MS Visual
    >>>> Studio I must set the crt-libs for multithreaded.
    >>>> Do I need this for g++? Is there a falg (linker / compiler) for using
    >>>> multithread?
    >>>
    >>> On most Unixes (including Mac OSX) you have to use -pthread für
    >>> compiling and linking.

    >>
    >> I don't know MacOS but I know the others, and I believe you're wrong.
    >> You have to link with the Pthreads library (-lpthread) to use the
    >> Pthreads functions, but there's nothing remarkable about that.
    >>
    >> There was in the distant past a #define _REENTRANT which prepared the
    >> C standard library for multithreaded use ... unsure which systems need
    >> it today, but that's easy to google for.
    >>
    >> /Jorgen
    >>

    >
    > No, -pthread implies -lpthread but also switches the compiler to
    > threaded mode (i.e. errno is thread local).
    >
    > From info g++:
    >
    > `-pthread'
    > Adds support for multithreading with the "pthreads" library. This
    > option sets flags for both the preprocessor and linker.


    Ah, sorry. I note though that that's an "IBM RS/6000 and PowerPC"
    option, and also on SPARC. So I guess it boils down to what someone
    else suggested: RTFM for your compiler, standard library and
    architecture.

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
     
    Jorgen Grahn, Aug 26, 2010
    #7
  8. On 25/08/10 08:38, Jorgen Grahn wrote:
    > On Tue, 2010-08-24, Lars Tetzlaff wrote:
    >> Am 24.08.2010 11:32, schrieb Philipp Kraus:
    >>> Hi,
    >>>
    >>> I hope, that my topic is not off-topic.
    >>> I try to compile with g++ 4.0.1 a multithreaded library. On MS Visual
    >>> Studio I must set the crt-libs for multithreaded.
    >>> Do I need this for g++? Is there a falg (linker / compiler) for using
    >>> multithread?

    >>
    >> On most Unixes (including Mac OSX) you have to use -pthread für
    >> compiling and linking.

    >
    > I don't know MacOS but I know the others, and I believe you're wrong.
    > You have to link with the Pthreads library (-lpthread) to use the
    > Pthreads functions, but there's nothing remarkable about that.


    With some compilers (don't remember whether it was gcc or Sun compiler)
    linking explicitly with -lpthread meant using the old threads library,
    as opposed to using -pthread or -mt for linking.

    --
    Max
     
    Maxim Yegorushkin, Aug 26, 2010
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RWtlbXBk?=

    Need an advice with this (multithread)

    =?Utf-8?B?RWtlbXBk?=, Feb 1, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    440
    Steve C. Orr [MVP, MCSD]
    Feb 1, 2005
  2. steve
    Replies:
    1
    Views:
    3,819
    Larry Barowski
    Jun 15, 2004
  3. Dimitri Ognibene
    Replies:
    1
    Views:
    332
    Oliver Wong
    May 1, 2006
  4. Michael Shestero

    stream in multiprocess (multithread) apps

    Michael Shestero, Dec 19, 2003, in forum: C++
    Replies:
    4
    Views:
    537
    Michael Shestero
    Dec 19, 2003
  5. r_obert@REMOVE_THIS.hotmail.com

    Multithread or Multithread DLL?

    r_obert@REMOVE_THIS.hotmail.com, Nov 27, 2004, in forum: C++
    Replies:
    0
    Views:
    2,241
    r_obert@REMOVE_THIS.hotmail.com
    Nov 27, 2004
Loading...

Share This Page