Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > multithread

Reply
Thread Tools

multithread

 
 
Philipp Kraus
Guest
Posts: n/a
 
      08-24-2010
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

 
Reply With Quote
 
 
 
 
Marcel Müller
Guest
Posts: n/a
 
      08-24-2010
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
 
Reply With Quote
 
 
 
 
Lars Tetzlaff
Guest
Posts: n/a
 
      08-24-2010
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
 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      08-24-2010
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
 
Reply With Quote
 
Jorgen Grahn
Guest
Posts: n/a
 
      08-25-2010
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 .
 
Reply With Quote
 
Lars Tetzlaff
Guest
Posts: n/a
 
      08-25-2010
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
 
Reply With Quote
 
Jorgen Grahn
Guest
Posts: n/a
 
      08-26-2010
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 .
 
Reply With Quote
 
Maxim Yegorushkin
Guest
Posts: n/a
 
      08-26-2010
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
profiling multithread: the locks in repaint manager Dimitri Ognibene Java 1 05-01-2006 04:38 PM
Need an advice with this (multithread) =?Utf-8?B?RWtlbXBk?= ASP .Net 5 02-01-2005 11:23 PM
Multithread or Multithread DLL? r_obert@REMOVE_THIS.hotmail.com C++ 0 11-27-2004 04:11 AM
debug multithread java application steve Java 1 06-15-2004 09:07 PM
stream in multiprocess (multithread) apps Michael Shestero C++ 4 12-19-2003 04:33 PM



Advertisments