. Advertisement .
..3..
. Advertisement .
..4..
I get an error
clang: error: unsupported option '-fopenmp'
when I try to run the following code:
clang -fopenmp program_name.c
How to fix clang: error: unsupported option ‘-fopenmp’. Please give me some good ideas.
After using homebrew to install libomp (
brew install libomp)
,you can compile an OpenMP program with this:clang -Xpreprocessor -fopenmp -I/usr/local/include -L/usr/local/lib -lomp main.c -o main
In case you are using C++, you should try this:
clang++ -Xpreprocessor -fopenmp -I/usr/local/include -L/usr/local/lib -lomp main.cpp -o main
Use Homebrew‘s LVM:
Then you have all the llvm binaries for
/usr/local/opt/llvm/bin
.Compile OpenMP Hello World.
omp_hello.c
In a file and use
It is possible that you will also need to replace
CPPFLAGS
by-I/usr/local/opt/llvm/include
This is how the makefile should look
Up-to-date
You might encounter an error in macOS 10.14 (Mojave).
This could mean that the macOS SDK headers will be missing from
/usr/include
. They were moved to the SDK with Xcode 10. Install the headers to/usr/include