Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
641 views
in Technique[技术] by (71.8m points)

windows - Meaning of options in mingw-w64 installer

In the MinGW-W64 online installer there are several fields you can select. However I cannot find any documentation on this, and the guesses I've made don't give me the behaviour I want.

Clearly a lot of work has gone into this project so it seems a pity that uptake is being held back by lack of basic documentation.

The "Version" and "Architecture" fields are self-explanatory but the other fields I have trouble with are (values shown as of current installer):

  • Threads, options posix and win32
  • Exception, options dwarf and sjlj
  • Build revision, options 0, 1, 2.

The values I chose on my previous install were win32, seh and 1 (clearly the options have changed since then but I am none the wiser as to what's what).

What are the pros and cons of each option, especially the threading model and exception handling, and which version is "best"?

The specific problems I have encountered using x86_64-win32-seh-rev1 are:

  • std::thread and std::condition_variable are not supported
  • When debugging (using Code::Blocks as IDE), if an exception is thrown it does not jump to the exception handler; selecting Next Line does nothing 3 times and then aborts the run.

I can cope with the debugging problem but it would be really nice to have working C++11 threads.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Exceptions

Please see this answer for all three models (dwarf, sjlj and seh).

Threads

You can decide what kind of threads you want to use: POSIX threads or Windows API threads. The posix threads have the advantage of portability; you can use your code on other posix platforms (eg. linux) without modifications. The win32 threading api is windows only. If you are 100% on windows and like it's api that's no problem though.

If you use new C++ features like std::thread the impact is less visible since you already have a standard api for threading. I'm not sure if there's really a big difference if you don't use posix- / win32 thread api directly (maybe std::thread native handles?)

See also: mingw-w64 threads: posix vs win32

Build revision

I guess that's just another version number since Mingw(-w64) follows GCC versions (4.8.x, 4.9.x etc.). If you don't need an specific build, you should use the latest version.

Threading issue

If the exception thrown is:

terminate called after throwing an instance of 'std::system_error'
  what():  Enable multithreading to use std::thread: Operation not permitted

then just link pthreads - and the problem is solved.


Recommendation

If you don't have reasons to use a specific option; my personal recommendation:

posix - dwarf - 2
  • Posix enable C++11 <thread>, <mutex> and <future>
  • dwarf is faster
  • 2 because it's the latest release

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...