[英]Compiling C with OpenMP on my mac
I am trying to compile the code: 我正在尝试编译代码:
#include <stdio.h>
#include <omp.h>
int main(){
#pragma omp parallel
{
printf("%d\t%d\n",omp_get_thread_num(), omp_get_num_threads());
}
return 0;
}
I tried both cc -o main.exe main.c and gcc -o main.exe main.c 我尝试了cc -o main.exe main.c和gcc -o main.exe main.c
Both ways I get "fatal error: 'omp.h' file not found" 两种方式都出现“严重错误:找不到'omp.h'文件”
So I downloaded the latest version of OpenMP . 因此,我下载了最新版本的OpenMP 。 Then in the terminal in the directory of the downloaded folder I typed make and then
然后在终端中的已下载文件夹的目录中,键入make,然后
sudo cp ./libiomp5.dylib /usr/lib/
but I am still having the same issue. 但我仍然遇到同样的问题。 How can I get this to compile?
我该如何进行编译?
您应该使用#if _OPENMP保护Openmp的include和函数调用,以支持不带openmp选项(gcc -fopenmp)的编译。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.