Friday, September 5, 2014

Threads and strings in C++ on Windows

It's been way too long since I felt I had anything to say and in fact these days I realize most of what I have said is irrelevant anyway. But my memory still sucks and I still work as a software consultant so I need to post this just so I'll know next time. Because it took me days to get this to work. Which might sound like I should maybe look for another career but... nah! I like this geekery.

So I just started working at Acorn Technology and still have no assignment (thank you, lord!) so I've been looking at C++11 and all fancy new stuff there is. I use the MinGW/Eclipse setup as I love freedom, but I've been running into all kinds of issues. It turns out that what you get from the "official MinGW site" mingw.org can't handle C++11 strings (like the to_string method). So I changed to the distro you can get from nuwen.net which can handle the strings but not threads. Sigh. But by now I have also installed mingw-get which is very handy for adding extra packages, so I add pthreads but in vain. Double sigh. (Actually by now there are a lot of things my bosses have said I should look into so I'm very happy I have 20 years' experience in keeping bosses happy while doing my shit. But still, another sigh.)

But then, finally, something useful keeps turning up on my internet searches - mingw-w64. 64-bit. Threads (not the winAPI threads that apparently suck but the C++ std::threads). Not a million "clever" ways to avoid a shitty solutions' flaws that is the rule if you run into something that actually does not work. How about strings? I install from SourceForge and change the path (exchange the C:\mingw\bin path to C:\Program Files (x86)\mingw-w64\i686-4.9.1-posix-dwarf-rt_v3-rev1\mingw32\bin\) and it works! On the command line as well as in Eclipse. Just like that! (Well...) For once something actually works on a Friday afternoon. :)

No comments: