Enable OpenMP support in clang on Mac OS X (sierra)

I am using Mac OS X Sierra and I found that clang (LLVM version 8.1.0 (clang-802.0.38)) does not support OpenMP: when I run clang -fopenmp program_name.c I got the following error:

clang: error: unsupported option '-fopenmp'

-fopenmp doesn't seem to support the -fopenmp flag.

I could not find the openmp library in homebrew. According to the LLVM website, LLVM already supports OpenMP. But I could not find a way to enable it at compile time.

Does this mean that the standard clang on a Mac does not support OpenMP? Could you offer any suggestions?

(When I switch to GCC to compile the same program (gcc installs with brew install gcc --without-multilib ), and the compilation is successful.)

+5
source share
2 answers

Indeed, the Apple clang provided does not support OpenMP.

+3
source

Try using Homebrew llvm:

 brew install llvm 

Then you have all llvm files in /usr/local/opt/llvm/bin . To compile an OpenMP Hello World program , for example, type

 /usr/local/opt/llvm/bin/clang -fopenmp -L/usr/local/opt/llvm/lib omp_hello.c -o hello 

You may also need to install CPPFLAGS with -I/usr/local/opt/llvm/include .

+1
source

Source: https://habr.com/ru/post/1267046/


All Articles