# Mac OpenMP-capable compiler?

**URL:** https://discourse.julialang.org/t/mac-openmp-capable-compiler/114112
**Category:** General Usage
**Created:** [May 10, 2024, 2:52pm UTC](https://discourse.julialang.org/t/mac-openmp-capable-compiler/114112 "2024-05-10T14:52:02Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [May 10, 2024, 2:52pm UTC](https://discourse.julialang.org/t/mac-openmp-capable-compiler/114112/1 "2024-05-10T14:52:02Z")

</div>

I am trying to test a package with a wrapped library in c++ that uses OpenMP. Is there a suitable compiler on the Mac that would be reliably present?

---

<div class="post-metadata">

### Author: ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)
#### Post date: [May 10, 2024, 7:45pm UTC](https://discourse.julialang.org/t/mac-openmp-capable-compiler/114112/2 "2024-05-10T19:45:19Z")

</div>

Clang?

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [May 10, 2024, 7:59pm UTC](https://discourse.julialang.org/t/mac-openmp-capable-compiler/114112/3 "2024-05-10T19:59:12Z")

</div>

Is it really generally available on the Mac?  
Mine came with g++ (apparently not THE g++, but some Mac bastard).  
It could not compile w/ OpenMP.

I solved it for myself with brew compiler and libomp, but I can’t really rely on that  
on other people’s machines, can I?

---

<div class="post-metadata">

### Author: ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)
#### Post date: [May 10, 2024, 8:08pm UTC](https://discourse.julialang.org/t/mac-openmp-capable-compiler/114112/4 "2024-05-10T20:08:25Z")

</div>

A recent macOS will have g++ aliased to clang.

What does `g++ --version` say?

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [May 10, 2024, 9:57pm UTC](https://discourse.julialang.org/t/mac-openmp-capable-compiler/114112/5 "2024-05-10T21:57:42Z")

</div>

% g++ --version  
Apple clang version 15.0.0 (clang-1500.1.0.2.5)  
Target: arm64-apple-darwin22.6.0  
Thread model: posix  
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

I was successful compiling the lib with:  
% clang++ --version  
Homebrew clang version 18.1.5  
Target: arm64-apple-darwin22.6.0  
Thread model: posix  
InstalledDir: /opt/homebrew/opt/llvm/bin

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [May 12, 2024, 12:55am UTC](https://discourse.julialang.org/t/mac-openmp-capable-compiler/114112/6 "2024-05-12T00:55:00Z")

</div>

> [@PetrKryslUCSD](#):
>
> but I can’t really rely on that  
> on other people’s machines, can I?

If you’re asking whether the default compiler toolchain XCode comes with OpenMP support, then the answer is “no”. Apple doesn’t seem to believe in OpenMP. If you’re asking whether there exist compilers for macOS supporting OpenMP, then the answer is “any other compiler than the default one will likely work”. As you found out, most people tend to install vanilla clang with openmp with homebrew. I believe just installing the llvm openmp package with homebrew, without the full compiler toolchain, should be sufficient for building openmp code with apple clang, but you may need to somehow inform the compiler where to find the openmp runtime.

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [May 12, 2024, 1:28am UTC](https://discourse.julialang.org/t/mac-openmp-capable-compiler/114112/7 "2024-05-12T01:28:01Z")

</div>

I understand.

How does one handle testing though? Is there anything one can rely on one testing packages? (Obviously, on the mac.)

---

<div class="post-metadata">

### Author: ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)
#### Post date: [May 12, 2024, 4:49am UTC](https://discourse.julialang.org/t/mac-openmp-capable-compiler/114112/8 "2024-05-12T04:49:32Z")

</div>

What’s wrong with using homebrew to install vanilla clang on a mac?  
This also works for CI.

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [May 12, 2024, 12:59pm UTC](https://discourse.julialang.org/t/mac-openmp-capable-compiler/114112/9 "2024-05-12T12:59:34Z")

</div>

Nothing. I just have no experience with this. So, is there a template for installing compilers on the Mac during a “build” of a package?

Just a note about my use case: I want to test package A, which depends on package B, which wraps a C++ lib.

---

<div class="post-metadata">

### Author: ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)
#### Post date: [May 12, 2024, 1:48pm UTC](https://discourse.julialang.org/t/mac-openmp-capable-compiler/114112/10 "2024-05-12T13:48:26Z")

</div>

If these are Julia packages, I’d use [BinaryBuilder](https://github.com/JuliaPackaging/BinaryBuilder.jl).  
You can try running the wizard. It will download the needed compilers, but anyone actually using the Julia package once you have it on yggdrasil will just download the `jll` without the need to build it at all – much faster, and much more reliable.  
It should have reasonable compilers available.
