一、下载windows版本的pthread
二、解压pthread到指定目录
我选择的目录是:e:\dev-cpp\pthread
完成后,该目录会多出三个文件夹:pre-built.2,pthreads.2,queueuserapcex。
三、配置dev-c++编译选项
1)点击“工具”→“编译选项”→“目录”→“c++包含文件”,浏览到刚才解压的pthread目录,选择e:\dev-cpp\pthread\pre-built.2\include,添加。
![]()
Windows下使用Dev-C++开发基于pthread.h的多线程程序
2)点击“工具”→“编译选项”→“目录”→“库”,浏览到刚才解压的pthread目录,选择e:\dev-cpp\pthread\pre-built.2\lib,添加。
四、如果出现“undefined reference to 'pthread_create”的错误,在编译器选项中要加 -lpthread参数![]()
Windows下使用Dev-C++开发基于pthread.h的多线程程序 五、最后附上一个简单的多线程的例子![]()
Windows下使用Dev-C++开发基于pthread.h的多线程程序