pthread vs. mthreads

classic Classic list List threaded Threaded
28 messages Options
12
Reply | Threaded
Open this post in threaded view
|

pthread vs. mthreads

Paul
Hi All,

I am trying to compile an application written for linux on windows,
using MinGW gcc version 4.5.2.

The linux version builds with the -pthread option passed to gcc.

For the windows build, I changed the -pthread option to -mthreads
in the makefile, which I run through MSYS. This builds.

However, what I cannot find any reference to anywhere, is what exactly
the difference is between -pthread and -mthreads. According to the gcc
man page:
-pthread
    Adds support for multithreading with the pthreads library.
    This option sets flags for both the preprocessor and linker.
-mthreads
    Support thread-safe exception handling on Mingw32. Code that relies
    on thread-safe exception handling must compile and link all code
    with the -mthreads option. When compiling, -mthreads defines -D_MT;
    when linking, it links in a special thread helper library
    -lmingwthrd which cleans up per thread exception handling data.

They sound different, but obviously using -pthreads doesn't work, even
with the pthreads-win32 compatability library, so it seems I must use
-mthreads. Are they actually equivilant, is it just an historical
anomoly that makes the windows command line option have a different
name to the linux one, or do they actually do different things? If they
do different things, does this mean that although I am using the
pthreads-win32 library, and although the application builds, there
might be subtle bugs in the code because it isn't compiled with the
correct command line option?

I assume what -pthreads actually does on linux is set some sort of
#define so that linked libraries know to use the correct thread-safe
code, and automatically links in the pthread library. This could then
be the same behaviour as the windows code, and all that talk of
thread-safe exception handling is just a documentation difference
between the two?

Basically, aside from maybe some background to help me better
understand, what I really want to know is am I doing the right thing by
changing the command line option to -mthreads instead of -pthread for
the windows build, and is there anything else I need to do, or must I
do something entirely different?

Many thanks for any help understanding this.

Paul Steyn

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: pthread vs. mthreads

Alessandro Antonello
Hi,

Besides all that, -mthreads instruct the compiler to use the Windows
runtime library
intended for multithreaded applications. This sets the _MT '#define'
which turns a bunch of
functions and structures, from the Windows headers, aimed for multithread.

The way I see, the -pthreads and -mthreads options have a relation
only in use. The
operations done by the compiler are all different.

Best regards,
Alessandro Antonello

2011/12/21 Paul <[hidden email]>:

> Hi All,
>
> I am trying to compile an application written for linux on windows,
> using MinGW gcc version 4.5.2.
>
> The linux version builds with the -pthread option passed to gcc.
>
> For the windows build, I changed the -pthread option to -mthreads
> in the makefile, which I run through MSYS. This builds.
>
> However, what I cannot find any reference to anywhere, is what exactly
> the difference is between -pthread and -mthreads. According to the gcc
> man page:
> -pthread
>    Adds support for multithreading with the pthreads library.
>    This option sets flags for both the preprocessor and linker.
> -mthreads
>    Support thread-safe exception handling on Mingw32. Code that relies
>    on thread-safe exception handling must compile and link all code
>    with the -mthreads option. When compiling, -mthreads defines -D_MT;
>    when linking, it links in a special thread helper library
>    -lmingwthrd which cleans up per thread exception handling data.
>
> They sound different, but obviously using -pthreads doesn't work, even
> with the pthreads-win32 compatability library, so it seems I must use
> -mthreads. Are they actually equivilant, is it just an historical
> anomoly that makes the windows command line option have a different
> name to the linux one, or do they actually do different things? If they
> do different things, does this mean that although I am using the
> pthreads-win32 library, and although the application builds, there
> might be subtle bugs in the code because it isn't compiled with the
> correct command line option?
>
> I assume what -pthreads actually does on linux is set some sort of
> #define so that linked libraries know to use the correct thread-safe
> code, and automatically links in the pthread library. This could then
> be the same behaviour as the windows code, and all that talk of
> thread-safe exception handling is just a documentation difference
> between the two?
>
> Basically, aside from maybe some background to help me better
> understand, what I really want to know is am I doing the right thing by
> changing the command line option to -mthreads instead of -pthread for
> the windows build, and is there anything else I need to do, or must I
> do something entirely different?
>
> Many thanks for any help understanding this.
>
> Paul Steyn
>
> ------------------------------------------------------------------------------
> Write once. Port to many.
> Get the SDK and tools to simplify cross-platform app development. Create
> new or port existing apps to sell to consumers worldwide. Explore the
> Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
> http://p.sf.net/sfu/intel-appdev
> _______________________________________________
> MinGW-users mailing list
> [hidden email]
>
> This list observes the Etiquette found at
> http://www.mingw.org/Mailing_Lists.
> We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.
>
> _______________________________________________
> You may change your MinGW Account Options or unsubscribe at:
> https://lists.sourceforge.net/lists/listinfo/mingw-users
> Also: mailto:[hidden email]?subject=unsubscribe



--
Alessandro Antonello

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: pthread vs. mthreads

Paul
Hi,

Thanks for the reply, but I'm still a little hazy on what that means
for my situation.

Alessandro Antonello wrote:
> The way I see, the -pthreads and -mthreads options have a relation
> only in use. The
> operations done by the compiler are all different.
Relation in use... do you mean they are equivilant, but each for their
respective platform? Or are you saying that although they do
the same sort of thing, they actually are *not* the same? If the
operations by the compiler are different, is that difference only in
what is necessary to accomodate the respective OS targets, or different
in some other way?

If they are different in some other way, what would
be the best way to get a program written for linux that uses -pthread
to compile on windows?

And do I need any other stuff, like -lpthreadGC2 (or a windows
equivilant)?

Also, one of my searches produced this:
http://article.gmane.org/gmane.comp.gnu.mingw.user/22844/match=mthread+pthread
>>> quote <<<
There is no -pthread option in the mingw gcc. What you should use is
-mthreads. (That does not have all the effects that -pthread has on
some other platform, though).
...
that you need to do the above might indicate that the software
you are trying to build for Windows hasn't necessarily been ported to
Windows
>>> end quote <<<

So it seems that -mthreads and -pthread correspond, but are not
equivilant. In my case I know that the application hasn't been ported
to windows, as that's what I'm trying to do. What I need to know is what
it would take to port it. Just using -mthreads has so far produced a
seemingly working binary, so the code can't be using anything too linux
specific, but is there a good chance that using -mthreads has made the
code unsound somehow, and if so what would I need to look out for in
the code that would need to be re-written, or what compiler options
could I use to ensure the binary I get is sound?

> Besides all that, -mthreads instruct the compiler to use the Windows
> runtime library
> intended for multithreaded applications.
Just out of interest, but all this *could* be done with normal command
line switches, and -mthreads is just a convenient shorthand, right? Or
does it do other stuff that can't be done any other way?

Thanks for the help

Paul

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: pthread vs. mthreads

sisyphus1

----- Original Message -----
From: "Paul"

>>>> quote <<<
> There is no -pthread option in the mingw gcc. What you should use is
> -mthreads. (That does not have all the effects that -pthread has on
> some other platform, though).
> ...
> that you need to do the above might indicate that the software
> you are trying to build for Windows hasn't necessarily been ported to
> Windows
>>>> end quote <<<

Yet the mingw port of gcc-4.5.2 that I downloaded came with
include/pthread.h, lib/libpthread.dll.a and bin/libpthread-2.dll - and it
works nicely for me.

I have:

########################################
C:\>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.5.2/lto-wrapper.exe
Target: mingw32
Configured with:
../gcc-4.5.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions
 --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug
 --enable-version-specific-runtime-libs --disable-werror --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.5.2 (GCC)
########################################

Cheers,
Rob


------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: pthread vs. mthreads

Alessandro Antonello
In reply to this post by Paul
Hi, Paul.

> Relation in use... do you mean they are equivilant, but each for their
> respective platform? Or are you saying that although they do
> the same sort of thing, they actually are *not* the same? If the
> operations by the compiler are different, is that difference only in
> what is necessary to accomodate the respective OS targets, or different
> in some other way?

Well, they are equivalent but they don't do the same thing. Using '-pthread'
GCC adds support for using pthreads library, setting flags both in the
preprocessor and in the linker stage. pthreads library is a default
multithreaded development in Linux, but not in Windows.

On Windows you can develop a multithreaded application without pthreads. Using
the Windows SDK. But you do need to use -mthreads so the compiler can add
thread-safe exception handling and compile to the right Windows runtime
library.

I don't know about libpthreadGC2.a. By your link seams a different library.

> So it seems that -mthreads and -pthread correspond, but are not
> equivilant. In my case I know that the application hasn't been ported
> to windows, as that's what I'm trying to do. What I need to know is what
> it would take to port it. Just using -mthreads has so far produced a
> seemingly working binary, so the code can't be using anything too linux
> specific, but is there a good chance that using -mthreads has made the
> code unsound somehow, and if so what would I need to look out for in
> the code that would need to be re-written, or what compiler options
> could I use to ensure the binary I get is sound?

I haven't done a port like that but I have successful created an application
using pthreads-w32. Although on Linux you can use -pthread to import and link
against libpthread.a, on Windows you will use -mthreads only to set the right
runtime library. You will need to import libpthread.a by your self. And look
in the documentation to see what differences you need to know about the
implementation in the two platforms.

> Just out of interest, but all this *could* be done with normal command
> line switches, and -mthreads is just a convenient shorthand, right? Or
> does it do other stuff that can't be done any other way?

I don't know for sure. I believe that you could do the same sort of thing
with another set of command line switches, but GCC does a lot of internal work
when searching for headers and libraries. So, IMO, sticking to the standard is
the best way to go.

Just for you know, the 'CL' compiler, the compiler that comes with Visual
Studio, has a command line switch to select the right runtime library. When
using '/MD' the compiler sets '_MT' define, tunning the Windows headers to
use multi thread stuff. Also it links with the correct runtime library for
multithreaded applications. The '-mthreads' on GCC mimics this behavior.

Regards,
Alessandro

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: pthread vs. mthreads

Earnie Boyd
Alessandro Antonello wrote:

> Hi, Paul.
>
>> Relation in use... do you mean they are equivilant, but each for their
>> respective platform? Or are you saying that although they do
>> the same sort of thing, they actually are *not* the same? If the
>> operations by the compiler are different, is that difference only in
>> what is necessary to accomodate the respective OS targets, or different
>> in some other way?
>
> Well, they are equivalent but they don't do the same thing. Using '-pthread'
> GCC adds support for using pthreads library, setting flags both in the
> preprocessor and in the linker stage. pthreads library is a default
> multithreaded development in Linux, but not in Windows.
>

The goal of pthread-win32 is to provide a POSIX standard library for
Windows.  The implementation though changes pthread_t from int to a
struct so be careful in assuming pthread_t is an int.

> On Windows you can develop a multithreaded application without pthreads. Using
> the Windows SDK. But you do need to use -mthreads so the compiler can add
> thread-safe exception handling and compile to the right Windows runtime
> library.
>
> I don't know about libpthreadGC2.a. By your link seams a different library.
>

See http://sourceware.org/pthreads-win32/faq.html

>> So it seems that -mthreads and -pthread correspond, but are not
>> equivilant. In my case I know that the application hasn't been ported
>> to windows, as that's what I'm trying to do. What I need to know is what
>> it would take to port it. Just using -mthreads has so far produced a
>> seemingly working binary, so the code can't be using anything too linux
>> specific, but is there a good chance that using -mthreads has made the
>> code unsound somehow, and if so what would I need to look out for in
>> the code that would need to be re-written, or what compiler options
>> could I use to ensure the binary I get is sound?
>
> I haven't done a port like that but I have successful created an application
> using pthreads-w32. Although on Linux you can use -pthread to import and link
> against libpthread.a, on Windows you will use -mthreads only to set the right
> runtime library. You will need to import libpthread.a by your self. And look
> in the documentation to see what differences you need to know about the
> implementation in the two platforms.
>

See http://sourceware.org/pthreads-win32/faq.html

>> Just out of interest, but all this *could* be done with normal command
>> line switches, and -mthreads is just a convenient shorthand, right? Or
>> does it do other stuff that can't be done any other way?
>
> I don't know for sure. I believe that you could do the same sort of thing
> with another set of command line switches, but GCC does a lot of internal work
> when searching for headers and libraries. So, IMO, sticking to the standard is
> the best way to go.
>
> Just for you know, the 'CL' compiler, the compiler that comes with Visual
> Studio, has a command line switch to select the right runtime library. When
> using '/MD' the compiler sets '_MT' define, tunning the Windows headers to
> use multi thread stuff. Also it links with the correct runtime library for
> multithreaded applications. The '-mthreads' on GCC mimics this behavior.
>

See http://sourceware.org/pthreads-win32/faq.html

--
Earnie
-- https://sites.google.com/site/earnieboyd/

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: pthread vs. mthreads

Vincent Torri
In reply to this post by Alessandro Antonello


On Fri, 23 Dec 2011, Alessandro Antonello wrote:

> Hi, Paul.
>
> On Windows you can develop a multithreaded application without pthreads. Using
> the Windows SDK. But you do need to use -mthreads so the compiler can add
> thread-safe exception handling and compile to the right Windows runtime
> library.

Am I wrong if I suppose that "thread-safe exception handling" is for c++
code ? (I don't know much that stuff)

If yes, is just passing -D_MT to the preprocessor sufficient for dealing
with threads with a C only project with mingw (hence, -mthreads would be
useless) ?

I ask because -mthreads links in -lmingwthr and i don't want that.

thank you

Vincent Torri

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: pthread vs. mthreads

Earnie Boyd
Vincent Torri wrote:

>
>
> On Fri, 23 Dec 2011, Alessandro Antonello wrote:
>
>> Hi, Paul.
>>
>> On Windows you can develop a multithreaded application without pthreads. Using
>> the Windows SDK. But you do need to use -mthreads so the compiler can add
>> thread-safe exception handling and compile to the right Windows runtime
>> library.
>
> Am I wrong if I suppose that "thread-safe exception handling" is for c++
> code ? (I don't know much that stuff)
>

I don't think just c++.

> If yes, is just passing -D_MT to the preprocessor sufficient for dealing
> with threads with a C only project with mingw (hence, -mthreads would be
> useless) ?
>

No.

> I ask because -mthreads links in -lmingwthr and i don't want that.

You need -lmingwthr also.

--
Earnie
-- https://sites.google.com/site/earnieboyd/

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: pthread vs. mthreads

Paul
In reply to this post by Earnie Boyd
Hi,

Thanks to Alessandro and Earnie for your replies.

> > Well, they are equivalent but they don't do the same thing.
Best I can figure is that they do different things, as they are for
different OS targets, but that they do equivalent things as far as the
final compiled application is concerned. I'm surprised this issue
doesn't come up more often, and doesn't have a well defined answer.

> > Using '-pthread' GCC adds support for using pthreads library,
> > setting flags both in the preprocessor and in the linker stage.
> > pthreads library is a default multithreaded development in Linux,
> > but not in Windows.
> >
> The goal of pthread-win32 is to provide a POSIX standard library for
> Windows.  The implementation though changes pthread_t from int to a
> struct so be careful in assuming pthread_t is an int.
There is a pthread implementation with MinGW, is this the
pthreads-win32 implementation, or one with a similar goal? In either
case, this would mean if one is compiling with MinGW, one would not
need to download pthreads-win32 seperately? If they are not the same
implementation, does the MinGW one also make pthread_t a struct?

> > I don't know about libpthreadGC2.a. By your link seams a different
> > library.
> See http://sourceware.org/pthreads-win32/faq.html
Ok, I see, that link does clear up the naming of libpthreadGC2.a. But,
as I am not expressly linking in any particular file, I'm assuming
MinGW has, in essence, made the correct choice of which file to link
against. One assumes that that is part of what -mthreads does (or that
MinGW only provides one, pre-selected file to link against).

Does the MinGW implementation use the same exception handling scheme
that the linux pthreads implementation uses (structured EH, C++ EH, or
setjmp/longjmp)? Which one is that?

I see that the MinGW library is libpthread.dll.a, which is confusing,
does that mean that the code is dynamically linked to a pthread dll that
I will need to distribute with the compiled application, or is the
pthread code linked statically?

> > I haven't done a port like that but I have successful created an
> > application using pthreads-w32. Although on Linux you can use
> > -pthread to import and link against libpthread.a, on Windows you
> > will use -mthreads only to set the right runtime library. You will
> > need to import libpthread.a by your self.
How is this done? I assume that no command line parameters are needed
to do this, as I didn't use anything but -mthreads when building the
application on windows, and it built without errors. I also see nothing
in the code other than a #include <pthread.h>

> > And look in the
> > documentation to see what differences you need to know about the
> > implementation in the two platforms.
Sorry, what documentation is this? The man page on linux obviously only
talks about the linux pthreads implementation, where do I find any
documentation about the windows implementation and any differences that
there might be?

I have tried the pthreads-win32 manual, but I don't see anything
relevant there, other than thread priority levels. As asked above, I'm
not sure if this is relevant to the MinGW implementation of pthread.

> See http://sourceware.org/pthreads-win32/faq.html
Sorry, Earnie, I don't find much else there that is useful to a
comparison of the two implementations.

Again, many thanks for the help so far.

Paul

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: pthread vs. mthreads

Earnie Boyd
Paul wrote:

> Hi,
>
> Thanks to Alessandro and Earnie for your replies.
>
>>> Well, they are equivalent but they don't do the same thing.
> Best I can figure is that they do different things, as they are for
> different OS targets, but that they do equivalent things as far as the
> final compiled application is concerned. I'm surprised this issue
> doesn't come up more often, and doesn't have a well defined answer.
>

I think it is just raising its head because pthread library wasn't
delivered until GCC 4.  See
http://thread.gmane.org/gmane.comp.gnu.mingw.user/36035/focus=36049 for
talk of including the pthreads-dev package along with GCC.  It has to do
with the use of -fopenmp.  Originally pthreads-win32 was only supposed
to be used by GCC itself.

I agree it is confusing.

--
Earnie
-- https://sites.google.com/site/earnieboyd/

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: pthread vs. mthreads

Alessandro Antonello
In reply to this post by Paul
Hi, Paul.

> There is a pthread implementation with MinGW, is this the
> pthreads-win32 implementation, or one with a similar goal? In either
> case, this would mean if one is compiling with MinGW, one would not
> need to download pthreads-win32 seperately? If they are not the same
> implementation, does the MinGW one also make pthread_t a struct?

As I can see in the 'pthread.h' header is the standard pthread-w32
implementation, and yes, 'pthread_t' is a structure.

> Does the MinGW implementation use the same exception handling scheme
> that the linux pthreads implementation uses (structured EH, C++ EH, or
> setjmp/longjmp)? Which one is that?

Yes, 'setjmp/longjmp' by default. You can set '__CLEANUP_SEH', '__CLEANUP_CXX'
or '__CLEANUP_C' (the default) if you want. This is documented in the
'pthread.h' file.

> I see that the MinGW library is libpthread.dll.a, which is confusing,
> does that mean that the code is dynamically linked to a pthread dll that
> I will need to distribute with the compiled application, or is the
> pthread code linked statically?

The name 'libpthread.dll.a' stands for a library used to link dynamically with
the DLL. Yes, that means you'll need to distribute your application with the
pthread DLL. Thats why I linked my app with 'libpthread.a' manually. I was
building a DLL and didn't want to depend on another DLL.

> How is this done? I assume that no command line parameters are needed
> to do this, as I didn't use anything but -mthreads when building the
> application on windows, and it built without errors. I also see nothing
> in the code other than a #include <pthread.h>

I write my makefiles manually. I included all needed arguments, like
'-mthreads', and added '-lpthread' to the linker part. Sudenlly, I cannot find
this file anymore in my Mingw32 installation. Since this has quite some time,
Mingw32 may don't have this file anymore. This means that only the dynamic
linked version is available.

> Sorry, what documentation is this? The man page on linux obviously only
> talks about the linux pthreads implementation, where do I find any
> documentation about the windows implementation and any differences that
> there might be?

May I be sorry. I used Google to search for PThreads information and don't
remember where I found it. I never used PThreads in any POSIX equipment. I
used the documentation mostly to understand the differences between PThreads
and Windows Threads that I was more aware about. I can't tell you what kind of
differences you will find between POSIX and Windows implementation.

What I can tell you is that PThreads-w32 works beautifully in a Windows
environment. Be aware that you should never kill a thread. Even when using
Windows Threads. You must always return from your thread function cleanly.

Best regards,
Alessandro.

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual
desktops for less than the cost of PCs and save 60% on VDI infrastructure
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: pthread vs. mthreads

Earnie Boyd
Alessandro Antonello wrote:
--8<--
> I was building a DLL and didn't want to depend on another DLL.

Why not?  It happens all the time even in the Windows API.  The size of
your DLL is now larger including and potentially exporting the static
pthread library.

--
Earnie
-- https://sites.google.com/site/earnieboyd/

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual
desktops for less than the cost of PCs and save 60% on VDI infrastructure
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: pthread vs. mthreads

Alessandro Antonello
>> I was building a DLL and didn't want to depend on another DLL.
>
> Why not?  It happens all the time even in the Windows API.  The size of
> your DLL is now larger including and potentially exporting the static
> pthread library.

Oh, yes! You are right about that. I also was using FFmpeg library (almost all
of it), that uses PThread and, I thing, exports the global symbols. So I
needed to use it statically that time, because the compiler was doing some
wrong assumptions about function linking. I had several weird errors and the
way I could solve then was linking 'pthreads' statically.
--
Alessandro Antonello

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual
desktops for less than the cost of PCs and save 60% on VDI infrastructure
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: pthread vs. mthreads

Paul
In reply to this post by Earnie Boyd
Hi All,

Sorry, I'm re-asking certain questions that haven't been answered yet,
just so they don't get lost along the way.

> I think it is just raising its head because pthread library wasn't
> delivered until GCC 4.  See
> http://thread.gmane.org/gmane.comp.gnu.mingw.user/36035/focus=36049
> for talk of including the pthreads-dev package along with GCC.  It
> has to do with the use of -fopenmp.  Originally pthreads-win32 was
> only supposed to be used by GCC itself.
So I assume this means the pthread library I have with MinGW is the
pthreads-win32 package?

As far as I can tell from that discussion, pthreads-win32 doesn't play
nice with static linking, so I will need to distribute something with
the final exe. Can you tell me which file (or files) that is? Or can I
take it from the comment about recent improvements in CVS (and given
the comment was from April), that the latest pthreads lib in MinGW does
build statically without modifying the app?

Also, do I need the -lpthread switch as well, or does -mthreads imply
this? The conversation makes it seem like I will need this as well, but
my app built without it. I gather from the pthreads-win32 FAQ that
I shouldn't use -lpthread *instead* of -mthreads?

> > And look in the
> > documentation to see what differences you need to know about the
> > implementation in the two platforms.  
Again, what documentation? I see non on either the MinGW or
pthreads-win32 sites that address this point.

I'm also still hazy on the whole exception handling thing. Does the
MinGW implementation use the same exception handling scheme that the
linux pthreads implementation uses (structured EH, C++ EH, or
setjmp/longjmp)? Which one is that? I've tried a couple of man pages
for pthreads on linux, but can't find any mention of this issue.

Thanks again to everybody so far.

Paul

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: pthread vs. mthreads

Alessandro Antonello
Hi, Paul.

> So I assume this means the pthread library I have with MinGW is the
> pthreads-win32 package?

Well, if you type `mingw-get show pthreads' in your MSYS shell you will get
the answer for that question.

> As far as I can tell from that discussion, pthreads-win32 doesn't play
> nice with static linking, so I will need to distribute something with
> the final exe.

I think that the problem is with Windows. The MinGW distribution only has
the DLL version while Cygwin has only the static library version.

> Can you tell me which file (or files) that is? Or can I take it from the
> comment about recent improvements in CVS (and given the comment was from
> April), that the latest pthreads lib in MinGW does build statically without
> modifying the app?

> Also, do I need the -lpthread switch as well, or does -mthreads imply this?
> The conversation makes it seem like I will need this as well, but my app built
> without it. I gather from the pthreads-win32 FAQ that I shouldn't use
> -lpthread *instead* of -mthreads?

The command: `mingw-get install pthreads' will install all the libraries and
binaries you'll need (I think). In the current distribution it installs 5
archives:

- libpthread.a
- libpthread.dll.a
- libpthreadGC2.dll.a
- libpthreadGCE2.dll.a
- pthreadGC2.dll

Using the command `dlltool --identify' against the archives I could see
the all, except the file 'libpthreadGCE2.dll.a', point to 'pthreadGC2.dll'
dynamic library. I think that is the one.

Also, I thought that using `-mthreads', GCC would add `-lpthread' automatically
in the linker part but, now, I can't say it anymore. I think you could use
`-mthreads' so that GCC can tune the Windows headers to work with multiple
threads. Using `-lpthread' doesn't has any advantage right now.

> Again, what documentation? I see non on either the MinGW or pthreads-win32
> sites that address this point.

Using `mingw-get install pthreads' also install some documentation in the path
'/mingw/share/doc/pthreads-w32/2.9.0/manual' in HTML format. I don't know if
it has what you are looking for.

> I'm also still hazy on the whole exception handling thing. Does the MinGW
> implementation use the same exception handling scheme that the linux pthreads
> implementation uses (structured EH, C++ EH, or setjmp/longjmp)? Which one is
> that? I've tried a couple of man pages for pthreads on linux, but can't find
> any mention of this issue

'setjmp/longjmp' by default. You can set '__CLEANUP_SEH', '__CLEANUP_CXX'
or '__CLEANUP_C' (the default) if you want. This is documented in the
'pthread.h' file.

Best regards,
Alessandro.

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: pthread vs. mthreads

revelator
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

add -lws2_32 to LIBS and static linking to pthread works. Old
workaround used in many gcc builds with gomp to avoid more dependencies.

Ralph
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJPA6wNAAoJEIjGvG7Y4HU8AkQH/3rLAsLJgOUMp4RSCbp1E0rY
P6oeX0kpksDk6OgSgLOXbma8My1NaHe1e0K9uXV8XGzQTVp4JZEm46myG0zeWOHh
vnLc1xKVN5T7pUE3i/zYIgLXxiM86FdLMImiryiqOzxNO4E5w200f3kJTOkB9jJh
mKKWATKkZl3O7AcN4Z3fj+l0Yqi/ptLk8AzR3WUt3FkvEaLeC09FvwgTJmDAvnw4
ZDs6l8kantm1/PHZJlGKbBUqk4Ak12NqPO21q9x5vg1hCOCHpIvdhaS8H1Oah+nm
KAYlfHU0dqXMckjYAEfPp+9heXqBz1lxYUYBdiSbArRXUxY5Jc9K24ZlNgV0DoM=
=hAu5
-----END PGP SIGNATURE-----

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual
desktops for less than the cost of PCs and save 60% on VDI infrastructure
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: pthread vs. mthreads

Paul
In reply to this post by Alessandro Antonello
Hi,

again thanks for the help.


On Tue, 3 Jan 2012 18:53:14 -0200
Alessandro Antonello <[hidden email]> wrote:

> Hi, Paul.
>
> > So I assume this means the pthread library I have with MinGW is the
> > pthreads-win32 package?
>
> Well, if you type `mingw-get show pthreads' in your MSYS shell you
> will get the answer for that question.
Sorry, all I get is:
===snip======================================================================
$ mingw-get show pthreads

Package: mingw32-pthreads-w32                         Subsystem: mingw32
Components: dev, doc, lic

POSIX threading library for Win32
---------------------------------

pthreads-w32 seeks  to  provide  a  freely  available  and  high-quality
implementation  of  pthreads for Windows. Pthreads is an API for writing
multithreaded applications following the POSIX standard.

The mingw32-pthreads-w32 package  provides  the  documentation  for  the
pthreads-w32  library,  as  well  as  the related development files. The
associated mingw32-libpthread package provides the runtime library.
===snip===================================================================

not to be facetious, but while the name would suggest it is the same
package, it's also such a logical choice for a pthreads implementation
that I didn't want to assume that as proof of anything.

However, I'll assume you mean to say that they are the same thing.

> Using the command `dlltool --identify' against the archives I could
> see the all, except the file 'libpthreadGCE2.dll.a', point to
> 'pthreadGC2.dll' dynamic library. I think that is the one.
Yes, I see it, thanks. But according to the announcement of the latest
pthreads-win32 (http://sourceware.org/pthreads-win32/announcement.html)
I need to distribute pthreadGC.dll with my app, which I can't find.
What gives?

> Also, I thought that using `-mthreads', GCC would add `-lpthread'
> automatically in the linker part but, now, I can't say it anymore. I
> think you could use `-mthreads' so that GCC can tune the Windows
> headers to work with multiple threads. Using `-lpthread' doesn't has
> any advantage right now.
Sorry, I'm confused, what is the difference between using a -l to
include a library and a #include in the source file? I mean, I thought
I knew the difference, until you said this bit. Because surely just
including a "#include <pthread.h>" isn't enough, you need to specify the
-lpthread as well ? Although the proof is that I didn't when building,
so obviously I'm wrong...

> Using `mingw-get install pthreads' also install some documentation in
> the path '/mingw/share/doc/pthreads-w32/2.9.0/manual' in HTML format.
> I don't know if it has what you are looking for.
Odd. I had pthreads installed, but no pthreads folder
under /mingw/share/doc. I ran mingw-get install pthreads again, and it
upgraded from 2.8.0 to 2.9.0, and now I have the documentation.
I'll peruse that, thanks

> 'setjmp/longjmp' by default. You can set '__CLEANUP_SEH',
> '__CLEANUP_CXX' or '__CLEANUP_C' (the default) if you want. This is
> documented in the 'pthread.h' file.
I take it you mean this is the MinGW default pthreads-win32
implementation. But what is the default linux method, I can't seem to
find that in the man pages.

Thanks again, you're all being really helpful.

Paul

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual
desktops for less than the cost of PCs and save 60% on VDI infrastructure
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: pthread vs. mthreads

Paul
In reply to this post by revelator
Hi,

Thanks, Ralph, I'll try this.

Out of interest, what is ws2_32?

And what is gomp?

Sorry, sometimes for all my dev experience (mostly Delphi, C# and ooold
Turbo C) I feel like a complete noob :)

Paul



On Wed, 04 Jan 2012 02:31:57 +0100
Ralph Engels <[hidden email]> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> add -lws2_32 to LIBS and static linking to pthread works. Old
> workaround used in many gcc builds with gomp to avoid more
> dependencies.
>
> Ralph
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iQEcBAEBAgAGBQJPA6wNAAoJEIjGvG7Y4HU8AkQH/3rLAsLJgOUMp4RSCbp1E0rY
> P6oeX0kpksDk6OgSgLOXbma8My1NaHe1e0K9uXV8XGzQTVp4JZEm46myG0zeWOHh
> vnLc1xKVN5T7pUE3i/zYIgLXxiM86FdLMImiryiqOzxNO4E5w200f3kJTOkB9jJh
> mKKWATKkZl3O7AcN4Z3fj+l0Yqi/ptLk8AzR3WUt3FkvEaLeC09FvwgTJmDAvnw4
> ZDs6l8kantm1/PHZJlGKbBUqk4Ak12NqPO21q9x5vg1hCOCHpIvdhaS8H1Oah+nm
> KAYlfHU0dqXMckjYAEfPp+9heXqBz1lxYUYBdiSbArRXUxY5Jc9K24ZlNgV0DoM=
> =hAu5
> -----END PGP SIGNATURE-----
>
> ------------------------------------------------------------------------------
> Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a
> complex infrastructure or vast IT resources to deliver seamless,
> secure access to virtual desktops. With this all-in-one solution,
> easily deploy virtual desktops for less than the cost of PCs and save
> 60% on VDI infrastructure costs. Try it free!
> http://p.sf.net/sfu/Citrix-VDIinabox
> _______________________________________________ MinGW-users mailing
> list [hidden email]
>
> This list observes the Etiquette found at
> http://www.mingw.org/Mailing_Lists.
> We ask that you be polite and do the same.  Disregard for the list
> etiquette may cause your account to be moderated.
>
> _______________________________________________
> You may change your MinGW Account Options or unsubscribe at:
> https://lists.sourceforge.net/lists/listinfo/mingw-users
> Also:
> mailto:[hidden email]?subject=unsubscribe


------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual
desktops for less than the cost of PCs and save 60% on VDI infrastructure
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: pthread vs. mthreads

Alessandro Antonello
In reply to this post by Paul
Hi, Paul.

> I need to distribute pthreadGC.dll with my app, which I can't find.
> What gives?

Mine is in the 'mingw/bin' folder. Yours should be there too. On Windows if a
DLL is not in the application directory it must be in one of the system
folders (Windows or System32/64), or in a folder listed in the PATH
environment variable.

> Sorry, I'm confused, what is the difference between using a -l to
> include a library and a #include in the source file? I mean, I thought
> I knew the difference, until you said this bit. Because surely just
> including a "#include <pthread.h>" isn't enough, you need to specify the
> -lpthread as well ? Although the proof is that I didn't when building,
> so obviously I'm wrong...

What I did mean is using `-mthreads' should add `-lpthread' automatically.
`-mthreads' is mandatory because instructs GCC to tune Windows SDK headers to
use the multi threaded version of the run time library (msvcrt{*}.dll). Also
the linker will use the appropriate library archive (msvcrt{*}.a).

If you use just `-mthreads', compile and linking are OK and your application
runs just fine, then probably GCC is already adding `-lpthread' for you and you
will find the 'pthreadGC2.dll' DLL somewhere in your PATH environment
variable.

If your app don't compile, take a look on the errors. There you'll see that
'pthreads.h' header file probably is missing.

If your app don't link the errors should show you that a library is missing.
Then you should add '-lpthreads' in the linker command line.

If your app compile and link but doesn't run. Then probably the
'pthreadGC2.dll' was not found. You can download one or upgrade your MinGW
installation.

> > 'setjmp/longjmp' by default. You can set '__CLEANUP_SEH',
> > '__CLEANUP_CXX' or '__CLEANUP_C' (the default) if you want. This is
> > documented in the 'pthread.h' file.
> I take it you mean this is the MinGW default pthreads-win32
> implementation. But what is the default linux method, I can't seem to
> find that in the man pages.

Well, I can't tell you that. I don't have a Linux box so I don't know. But I
think that a good choice would be '__CLEANUP_C' (uses setjmp/longjmp) because
it is supported in almost all platforms.

Regards,
Alessandro

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual
desktops for less than the cost of PCs and save 60% on VDI infrastructure
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: pthread vs. mthreads

Earnie Boyd

On Fri, Jan 6, 2012 at 1:27 PM, Alessandro Antonello wrote:

What I did mean is using `-mthreads' should add `-lpthread' automatically.
`-mthreads' is mandatory because instructs GCC to tune Windows SDK headers to
use the multi threaded version of the run time library (msvcrt{*}.dll). Also
the linker will use the appropriate library archive (msvcrt{*}.a).


No it doesn't.  -mthreads adds -lmingwthrd and defines _MT.

If you want to use -lpthread you have to add it specifically and do not use -mthreads.  That said, I don't know much more than that but -lmingwthrd was created for thread safety and exception handling for Windows thread model.  The -lpthread is not in the specs when you gcc -dumpspecs and the specs is the clue as to what command line options GCC adds to the sub-processes.

--
Earnie


------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual
desktops for less than the cost of PCs and save 60% on VDI infrastructure
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
12