2011/9/10 Simson Garfinkel <simsong(a)acm.org>:
Hi. I'm still trying to get pthreads working reliably on mingw32 and
mingw64.
My question today --- if I am writing multi-threaded code, do i need to
supply the -mthreads compiler option?
Thanks
Well, this depends on the runtime-version you are using. Newer
version supports TLS-callbacks and so -mthreads is an nop-operation
for them, but for older runtime-versions it is mandatory to use it for
multi-threaded applications, which are using C++.
You should make sure in general to use shared libgcc and libstdc++, if
you are building an C++ application. This avoids some troubles you
otherwise might get into.
The pthread library doesn't depend on the -mthreads feature.
So in doubt, specify the -mthreads option and the additional the
options -shared-libgcc -shared-libstdc++.
Regards,
Kai