Hello Doug (and Öö)!
On Friday, July 17, 2015 at 2:26:00 PM UTC-4, Öö Tiib wrote:
> On Friday, 17 July 2015 20:54:00 UTC+3, Doug Mika wrote:
> > ...
> > I have NetBeans with MinGW installed, and I have not been able to figure out how to get threads to work on it...for a while now. Tutorialspoint IDE allowed for threading with merely the -pthreads tag.
>
> Not sure what the trick is with you. If to select pthread from the mingw-w64
> installer then threads work out of the box.
>
> Hmm ... perhaps it is because you use win32? Last 6 years it has been quite
> unlikely to buy new computer that is incapable of running 64 bit operating
> system.
>
> If you for whatever reason use mingw-w32 then perhaps you need to take
> std::thread and sync primitives implementation for it from somewhere.
> That looks good:
https://github.com/meganz/mingw-std-threads
(As an aside, the last time I looked at mingw-std-threads, it
wasn't really there yet. But that was at least half a year ago,
if not more.)
Just to clarify, mingw and mingw-w64 are two separate projects,
the latter a fork of the former, and they have two separate
mailing lists.
mingw does not support (non-native-windows) threads out of the
box, and does not support std::thread.
mingw-w64 does offer versions that support both pthreads (posix
c-style threads) and std::thread (c++11 threads) out of the box.
(But you will need to tell g++ to turn on c++11 features to
get std::thread, e.g., "-std=c++11" or "-std=c++14" or similar.)
You can run the mingw version with pthreads-win32 (a separate
download), to get pthreads, but this won't get you std::thread.
I have been using mingw-w64 with std::thread for some time now.
(I don't really use pthreads.)
(Also, mingw offers only a 32-bit version -- runs as a 32-bit
application and produces 32-bit code -- while mingw-w64 offers
both 32-bit and 64-bit versions. mingw will run, of course, on
64-bit windows as a 32-bit application. It will produce 32-bit
applications that will run on 64-bit windows. But if you need
to produce 64-bit applications, you will need mingw-w64.)
If you have further questions about either of these two ports
of gcc to windows, you are likely to get better-informed
responses on their respective mailing lists.
Happy Multi-Threaded hacking!
K. Frank