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!
本文详细介绍了如何使用 Eclipse IDE for C/C++ Developers 和 MinGW 构建 C/C++ 的开发环境,并通过一个简单的多线程示例程序验证了配置的成功。
9647

被折叠的 条评论
为什么被折叠?



