Using threads with MinGW?

爱⌒轻易说出口 提交于 2019-12-08 09:19:19

问题


I am building a small tool that will need to open a thread, and let the thread do its thing, no matter what happens on that thread I don't want it to interfere with the main app, just execute, handle errors and close.

How can I do this with mingw compiler? On linux I can use POSIX, but this tool will run only on win, both x86 and x64, so I've no idea how to do it.


回答1:


You can use pthreads-win32. It implements most of pthreads functionality using Windows threading API.

To find this, I searched Google for "pthreads mingw" and it was the first result.




回答2:


Unless you want to work directly with Windows threads you'll probably want a cross-platform thread library like pthreads-win32 or boost:thread




回答3:


You can find a working sample in this [thread][1] :) Threaded C programs in minGW

I made this using MinGW + Windows API + Eclipse CDT.

Regards



来源:https://stackoverflow.com/questions/6727796/using-threads-with-mingw

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!