Installing POSIX Threads

Although Red Hat’s pthread library is open source, I have chosen not to distribute it with the book and have only included the libs, dlls, and key headers. You can download the pthread library and find extensive documentation at http://sources.redhat.com/pthreads-win32. I encourage you to browse the site and get the latest version of Pthreads-Win32 from Red Hat. The pthreads library is composed of three header files, a library file, and a DLL runtime file (which must be distributed with the program’s executable). The three header files are:

  • pthread.h

  • sched.h

  • semaphore.h

These files should be copied to your compiler’s .include folder for best results. Optionally, you can add a folder to your compiler’s include path so that it can find the pthread headers (wherever you have copied them to your hard drive). Due to the way the pthread headers are defined, you cannot include them locally—they must be referenced globally by your compiler.

Second, you must copy the pthread library file into your compiler’s .lib folder, or add a library path to your compiler. For Dev-C++, the library file is called libpthreadGC.a, and you will add it as a linker option using -lpthreadGC. For Visual C++, the library file is called pthreadVC.lib, and you will add it to the list of additional dependencies by its filename: pthreadGC.lib.

Third, to run a program compiled with the pthread library, you must include the runtime DLL file. For Dev-C++, the file is pthreadGC.dll. For Visual C++, the file is pthreadVC.dll. The library file just provides a link between your program and the DLL, where the compiled pthread code is located and linked into your program at runtime. You will need to distribute the pthreadxx.dll file just as you must include the fmodex.dll file for FMOD audio support. If you’re a Dev-C++ user, you must also provide the custom d3dx9.dll for Direct3D support too (although this file is installed with the normal DirectX runtime when you build with Visual C++).

Advice

On the CD-ROM under libraries, you will find a folder called .pthreads that includes ready-to-use headers, libs, and DLLs for Dev-C++ and Visual C++. You may want to install these files in your compiler’s install folder in order to use the Pthreads-Win32 library.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset