I'm working on a MATLAB extension using some C++ code that is working with OpenMP for parallelisation for data processing. The mex file works well on Windows and Linux using OpenMP, while on macOS it works single threaded only. As llvm/clang on macOS/Xcode comes without OpenMP support, I compiled libomp myself as a static library with the code from the llvm projecthttp://llvm.org/svn/llvm-project/openmp/trunk. Building an executable from some OpenMP test code with a command like
c++ -Xpreprocessor -fopenmp -I/path/to/omp/include -lpthread -o testcode omptest.cpp /path/to/omp/libomp.a
The sample extensionhttps://bpaste.net/show/0c6f919e8662 works on Linux but not on macOS. The C++ code contains the mex compiler call I used on both systems and a sample how I called the mex function in the comments. Can anyone help how to get OpenMP running in a mex extension?