i am trying to run a code having pthreads lib in it but i cant run it it gives error with pthreads.h can any one look up and solve it? code is given below.. mY Os is Windows. is this problem with Os?
For every #include, you are specifying a file which exists on your hard-drive somewhere.
When compiling, a compiler does not know where to look. Some compilers will look in standard places like /usr/include or /usr/local/include. Since your header files may be installed anywhere, you have to tell the compiler where to look. This is known as an INCLUDE_PATH.
You can add as many paths to your INCLUDE_PATH as you like, but if you are using an IDE on Windows like Visual Studio, you have to find the settings where you can set your INCLUDE_PATH. However, before you do this, you have find where that pthread.h file is. For CygWin, it might be in:
/usr/sys/sinclude/
Your program has a race condition - even if you manage to compile this program, you can get unpredictable, erratic results.
I recommend that you tackle the basics of C, compiling, reading error messages, etc... ...before you attempt pthreads - doing so will save you many headaches and many hours.
If you are on windows, why do you need to use pthreads anyway ?
What's wrong with CreateThread(), _beginthread() or _beginthreadex() WinAPI functions ?
Your code posted does compile for me using MinGW and Visual Studio just fine.
@ modoran: The OP is using Cygwin, so even though his OS is windows they are technically writing in a *nix environment. This is NOT the route I would have suggested for any user to start writing C++ in for reasons just like this. +1 for your suggestion, I'm glad to see another competent Win32 contributor.
If you are on windows, why do you need to use pthreads anyway ?
What's wrong with CreateThread(), _beginthread() or _beginthreadex() WinAPI functions ?
It seems to check for what compiler and what language you are using then if for example, it finds that you are using MingW (which would indicate you are writting on Windows) it redefines a bunch of stuff so that either Win32 or POSIX terminology can be used when calling the functions that it defines from the DLL.
I'm not a pro at this but I think that when modoran called it a wrapper it was an accurate description.