-mthreads

Simson Garfinkel simsong at acm.org
Sun Sep 11 14:03:30 UTC 2011


>> 
>> 
>> 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++.

Kal, thanks for the information.

I am writing C++ code. We are attempting to create .EXE files that have no external dependencies and do not require the use of ANY DLL that is not part of the standard Windows system. 

Does  -shared-libgcc make the system require a GCC DLL? If so, we can't do that.

Specifying -mthreads creates a dependcy fir mingwm10.dll. According to some posts I've read the dependency goes away if you are using GCC 4.5.2 or above:

	• http://comments.gmane.org/gmane.comp.gnu.mingw.user/36738

It is not clear to me how to get the current mingw (32 or 64) running in cross-compiler mode on Ubuntu or MacOS. A while ago I looked at the Fedora build system and it was broken too. However, I need to build both 32-bit and 64-bit executables and I need a system that is repeatable for others, so it looks like I'm going to have to spend some serious time on this over the next 2-3 weeks. I am happy to do it with Fedora or Ubuntu or Mac, but I need something that's easy, and I need to generate both 32-bit and 64-bit binaries.

Have the Fedora repositories been fixed yet?



More information about the mingw mailing list