How to include omp.h in OS X?

This command can help you

brew install libomp

brew info libomp
libomp: stable 6.0.1 (bottled)
LLVM's OpenMP runtime library
https://openmp.llvm.org/
/usr/local/Cellar/libomp/6.0.1 (12 files, 1.2MB) *
  Poured from bottle on 2018-11-20 at 16:12:22
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/libomp.rb
==> Dependencies
Build: cmake ✘
==> Requirements
Required: macOS >= 10.10 ✔
==> Caveats
On Apple Clang, you need to add several options to use OpenMP's front end
instead of the standard driver option. This usually looks like
  -Xpreprocessor -fopenmp -lomp

You might need to make sure the lib and include directories are discoverable
if /usr/local is not searched:

  -L/usr/local/opt/libomp/lib -I/usr/local/opt/libomp/include

For CMake, the following flags will cause the OpenMP::OpenMP_CXX target to
be set up correctly:
  -DOpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include" -DOpenMP_CXX_LIB_NAMES="omp" -DOpenMP_omp_LIBRARY=/usr/local/opt/libomp/lib/libomp.dylib

Leave a Comment