Mac running OpenMP, "clang: error: unsupported option '-fopenmp'"

Viewed 5932

I am new to OpenMP, and my professor gives us a project to do. There are only three files in the folder: a C++ source code a0.cpp, a header a0.h, and a Makefile. When I want to run the code in my terminal, it says:

clang: error: unsupported option '-fopenmp'
clang: error: unsupported option '-fopenmp'
make: *** [a0] Error 1

I am using a Macbook, and I do not know how to fix this. Can you help me? Thanks.

1 Answers

After installing libomp with homebrew using:

brew install libomp

I was able to compile an OpenMP program with this:

clang -Xpreprocessor -fopenmp -I/usr/local/include -L/usr/local/lib -lomp  main.c -o main

If you are using C++, you'd likely want:

clang++ -Xpreprocessor -fopenmp -I/usr/local/include -L/usr/local/lib -lomp  main.cpp -o main
Related