0

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

Both ways I get "fatal error: 'omp.h' file not found"

So I downloaded the latest version of OpenMP. Then in the terminal in the directory of the downloaded folder I typed make and then

sudo cp ./libiomp5.dylib /usr/lib/

but I am still having the same issue. How can I get this to compile?

user906357
  • 4,575
  • 7
  • 28
  • 38
  • 1
    You installed the _library_ but _not_ the development package [or whatever] that has `omp.h`. The web site should have better/exact details on how to do this. – Craig Estey Sep 11 '16 at 22:45
  • Also on macOS you _can_ name your executables `.exe`, but you really _shouldn't_, or they might get associated with some application to be opened with. – Siguza Sep 11 '16 at 22:53
  • I'll look around their site more and see what I can find, so far nothing. I'm doing .exe since it will eventually be put onto a cray machine and they examples given use .exe – user906357 Sep 11 '16 at 23:06
  • Try this: http://stackoverflow.com/questions/35134681/installing-openmp-on-mac-os-x-10-11 – Craig Estey Sep 12 '16 at 00:39

1 Answers1

1

You should guard the Openmp include and function calls with #if _OPENMP in order to support compiling without the openmp option (gcc -fopenmp).

tim18
  • 580
  • 1
  • 4
  • 8