yutiansky 发表于 2013-1-19 04:11:57

搭建环境 Eclipse + MinGW + pthread

1,安装Eclipse IDE for C/C++ Developers
  从『http://www.eclipse.org/downloads/』下载安装包。
  直接展开就可以啦。
 
2,安装MinGW
  2.1,从『http://sourceforge.net/projects/mingw/files/MinGW/』下载安装包。
    直接安装就可以啦。
 
  2.2,然后必须把MinGW/bin加到环境变量 PATH 中。
 
3,测试一下。
  把pthread-win32中的测试程序join0.c。
  #我稍微修改了一些。打印写信息。
#include "test.h"void * func(void * arg) {printf("C : thread start!\n");Sleep(2000);printf("C : thread end!\n");pthread_exit(arg);/* Never reached. */exit(1);}int main(int argc, char * argv[]) {pthread_t id;int result;printf("M : create child thread!\n");assert(pthread_create(&id, NULL, func, (void *) 123) == 0);printf("M : wait for child thread!\n");assert(pthread_join(id, (void **) &result) == 0);printf("M : get child thread value!\n");assert(result == 123);printf("M : over!\n");return 0;} 
  结果是:
M : create child thread!M : wait for child thread!C : thread start!C : thread end!M : get child thread value!M : over!  
页: [1]
查看完整版本: 搭建环境 Eclipse + MinGW + pthread