1.在官网下载一个CodeBlocks(带mingw的版本);
2.配置编译器,在Selected Compiler选项中选GNU GCC Compiler ;
3.填写编译参数,Compiler Setting里的Other Options中粘贴-fopenmp ;
4.填写连接参数,Link Setting里的Other Options中粘贴-lgomp -lpthread ;
5 设置系统环境变量path
在path中添加D:\Program Files (x86)\CodeBlocks\MinGW\bin;D:\Program Files (x86)\CodeBlocks\MinGW\lib\gcc\mingw32\bin;
6 运行codeblocks
#include "stdio.h"
#include "omp.h"
#include "tchar.h"
//#include <iostream>
int _tmain(int argc,_TCHAR*argv[])
{
#pragma omp parallel
printf("核心数量i=%d, 线程编号=%d\n", omp_get_num_threads(), omp_get_thread_num());
return 0;
}
编译测试通过