Using pkg-config to find `libomp` on mac m1.

Pradyot Ranjan rickprimeranjan at gmail.com
Sat Feb 24 10:07:52 UTC 2024


On macOS, I have to use compiler options to find libomp, can they be
removed and we can use pkg-config from Homebrew that should be able to do
it automatically? The reason for this is because Apple Clang does not come
with the OpenMP specification – however, other compilers such as LLVM and
GCC do.

I tried doing `pkg-config --exists --print-errors libomp` but it throws
errors:

```
Package libomp was not found in the pkg-config search path.
Perhaps you should add the directory containing `libomp.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libomp' found
```
But with `clang -Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include
-o test test.c`
I'm able to compile successfully!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pkg-config/attachments/20240224/d37ce79a/attachment.htm>


More information about the pkg-config mailing list