【发布时间】:2015-12-11 15:55:17
【问题描述】:
我正在尝试学习如何使用 openMP,但在使用 Code::Blocks 时不断出错。
我按照推荐安装了MinGW版本,编译器设置如下。
设置 -> 编译器 -> 编译器设置 -> 其他选项,添加 -fopenmp。
然后在 Linker settings -> Other linker options 添加 -lgomp.
在尝试构建程序时,我收到消息
ld.exe||找不到-lgomp|
ld.exe||找不到-lgomp| ||=== 构建失败:2 个错误,0 个警告(0 分钟,0 秒)===|
我正在使用 GNU GCC 编译器,我尝试运行的程序如下。
#include <omp.h>
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char *argv[])
{
int nthreads, tid;
#pragma omp parallel private(nthreads, tid)
{
tid = omp_get_thread_num();
printf("Hello World from thread = %d\n", tid);
if (tid == 0)
{
nthreads = omp_get_num_threads();
printf("Number of threads = %d\n", nthreads);
}
}
}
我尝试了许多在线发布的解决方案,但似乎没有任何效果。我究竟做错了什么? 提前谢谢你。
【问题讨论】:
标签: gcc openmp codeblocks ld