使用 open mp 时出现编译错误
compilation error while using open mp
我正在尝试在我的项目中开始使用 open mp。
我有这样的代码:
#pragma omp for
for (i = 0; i < 16; i++) {
resBuf[i] = buf1[i] ^ buf2[i];
}
我在文件的开头包含了 <omp.h.>
。
我还尝试在 makefile 中使用不同的标志及其组合:
FLAGS = -Wall -g -fopenmp -lgomp -fgomp
CC = gcc
还是不行。存在以下问题:
undefined reference to `omp_get_num_threads'
undefined reference to `omp_get_thread_num'
undefined reference to `GOMP_barrier'
你能帮帮我吗?
只需在 gcc 命令行上使用 -fopenmp 即可:https://www.dartmouth.edu/~rc/classes/intro_openmp
我猜你的项目有单独的编译和链接步骤,并且链接命令行中缺少 -fopenmp。如果您的 makefile 没有 LDFLAGS 行,请尝试添加 LDFLAGS=-fopenmp 行,否则请将 -fopenmp 添加到该行。
我正在尝试在我的项目中开始使用 open mp。 我有这样的代码:
#pragma omp for
for (i = 0; i < 16; i++) {
resBuf[i] = buf1[i] ^ buf2[i];
}
我在文件的开头包含了 <omp.h.>
。
我还尝试在 makefile 中使用不同的标志及其组合:
FLAGS = -Wall -g -fopenmp -lgomp -fgomp
CC = gcc
还是不行。存在以下问题:
undefined reference to `omp_get_num_threads'
undefined reference to `omp_get_thread_num'
undefined reference to `GOMP_barrier'
你能帮帮我吗?
只需在 gcc 命令行上使用 -fopenmp 即可:https://www.dartmouth.edu/~rc/classes/intro_openmp
我猜你的项目有单独的编译和链接步骤,并且链接命令行中缺少 -fopenmp。如果您的 makefile 没有 LDFLAGS 行,请尝试添加 LDFLAGS=-fopenmp 行,否则请将 -fopenmp 添加到该行。