'How to install OpenMP on Mac M1?

I am currently studying to become a computer engineer and I need to work with OpenMP. After some research, I'm still having trouble installing it (#include <omp.h> is still not recognized). I tried libomp and llvm (with homebrew), but I must have made a mistake along the way. Has anyone been able to use OpenMP on mac M1?

Théo Souchon



Solution 1:[1]

A simple approach is to use brew https://brew.sh/ to install GCC or LLVM (clang), and then use that compiler. You need to tread carefully, though, since the MacOS environment includes X86 emulation which can be confusing.

https://cpufun.substack.com/p/setting-up-the-apple-m1-for-native might help, though it's now nearly a year old...

Solution 2:[2]

M1 chip seems doesn't install llvm in the proper location.

brew install llvm
cd /opt/homebrew/opt/libomp/lib

if libomp.dylib is in the folder /opt/homebrew/opt/libomp/lib:

cd /usr/local/lib
sudo ln -s /opt/homebrew/opt/libomp/lib/libomp.dylib libomp.dylib

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jim Cownie
Solution 2 Qin