Link to home
Start Free TrialLog in
Avatar of anAppBuilder
anAppBuilderFlag for United States of America

asked on

gcc std::thread vs boost::thread

I want to add threads to a multi-platform C++ application.  I've been using gcc with mingw on Win 7 and want to upgrade to mingw-w64.  When I start the install of mingw-w64 it asks whether I want POSIX or Windows threads.  

Does this mean there is no "standard" thread in C++2011?

Other sites imply that POSIX thread is an emulation on Windows and raise questions about it's reliability.  Is selecting POSIX threads on Windows a viable option?

Would it be safer for now to use boost::thread and wait for C++2014 to implement really standard threading?
Avatar of jkr
jkr
Flag of Germany image

>> Does this mean there is no "standard" thread in C++2011?

No, there for sure ins 'std::thread', see http://en.cppreference.com/w/cpp/thread/thread

>> Is selecting POSIX threads on Windows a viable option?

The both the POSIX and the C++11 encapsulation for threads (plus boost's) will end up using Windows APIs for threading anyway, and so will any other library.

From a multi-platform POV, I'd definitely go for either boost or C++11 (well, both being almost the same now), and if you plan to use C++11 features anyway, strike out pthreads from your considerations. If you however require backwards compatibility and no C++11 features, both boost and pthreads should remain considered.
Avatar of anAppBuilder

ASKER

Thank you, jkr.  

The problem is the mingw offers me p-threads or Windows threads.  There is no option for C++11 threads which is what I want.

Am I using the wrong tools?  Is there some other platform independent compiler I should be using?
What version of MinGW are we talking about? 4.7.2 or higher do support these features..
I went to this page GCC for both 64 & 32 bits Windows.

I selected this download:  Mingw-builds project - native toolchains using trunk.

Should I select this one? Win-builds project - stable, native- and cross- compilers plus libraries and a cross-platform package manager
In the former case, I selected gcc 4.8.3.

In the latter case the only choice would be gcc 4.8.2
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you, jkr.  It's taking me a while to get the new environment set up, so I can't yet tell you what is working (or not).
Thank you, jkr.  I selected POSIX and it works fine.
A few comments for the next person.

If you need make and the other utilities, you need msys which is not part of the download.  You can get it here.

I found this helpful in configuring Eclipse