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?

4
  • 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. Commented Sep 11, 2016 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. Commented Sep 11, 2016 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 Commented Sep 11, 2016 at 23:06
  • Try this: stackoverflow.com/questions/35134681/… Commented Sep 12, 2016 at 0:39

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.