title: Using OpenMP with C++11 on Mac OS
body: <p>I am trying to use some OpenMP multithreading features in my C++11 code like: </p>
  
  <pre><code>#pragma omp parallel for
  </code></pre>
  
  <p>When I try to compile using:</p>
  
  <pre><code>clang++ -std=c++11 -stdlib=libc++ -fopenmp main.cpp -o main.o
  </code></pre>
  
  <p>I get the below error:</p>
  
  <pre><code>clang: error: unsupported option '-fopenmp'
  </code></pre>
  
  <p>I alternatively tried compiling using:</p>
  
  <pre><code>g++ -fopenmp main.cpp -o main.o
  </code></pre>
  
  <p>But this gives the exact same error.</p>
  
  <p>Would appreciate very much if you could advise how can I compile C++11 code that has OpenMP features on Mac OS 10.12. The other questions on posts here and elsewhere explain compiling C code for OpenMP, however, I couldn't find anything for C++11.</p>
  
  <p>I get an error when I try to install libiomp, I get errors:</p>
  
  <pre><code>$ brew install libiomp
  ==&gt; Auto-updated Homebrew!
  Updated 1 tap (homebrew/core).
  ==&gt; Updated Formulae
  ansible-cmdb        djview4             khard               oysttyer            shyaml              yazpp             
  asciinema2gif       doctl               macvim              pazpar2             vala                you-get           
  avro-c              elixir              mailhog             python              vdirsyncer          youtube-dl        
  bash-git-prompt     file-roller         meson               python3             vim               
  commandbox          glib                metaproxy           rtv                 x265              
  consul-backinator   gtkextra            offlineimap         s-search            xonsh             
  
  Error: Could not link:
  /usr/local/share/doc/homebrew
  
  Please delete these paths and run `brew update`.
  Error: Could not link:
  /usr/local/share/man/man1/brew.1
  
  Please delete these paths and run `brew update`.
  Error: No available formula with the name "libiomp" 
  ==&gt; Searching for similarly named formulae...
  Error: No similarly named formulae found.
  ==&gt; Searching taps...
  Error: No formulae found in taps.
  </code></pre>
  
  <p>If I run using g++-6, based on Mark Setchell's post below, it works fine, thanks, I however get the below warnings, would appreciate any suggestions on how to avoid these:</p>
  
  <pre><code>$ /usr/local/bin/g++-6 -std=c++11 -fopenmp main.cpp -o main.o
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:4:11: warning: section "__textcoal_nt" is deprecated
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:4:11: note: change section name to "__text"
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:89:11: warning: section "__textcoal_nt" is deprecated
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:89:11: note: change section name to "__text"
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:551:11: warning: section "__textcoal_nt" is deprecated
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:551:11: note: change section name to "__text"
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:1432:11: warning: section "__textcoal_nt" is deprecated
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:1432:11: note: change section name to "__text"
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:1799:11: warning: section "__textcoal_nt" is deprecated
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:1799:11: note: change section name to "__text"
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:1995:11: warning: section "__textcoal_nt" is deprecated
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:1995:11: note: change section name to "__text"
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2033:11: warning: section "__textcoal_nt" is deprecated
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2033:11: note: change section name to "__text"
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2425:11: warning: section "__textcoal_nt" is deprecated
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2425:11: note: change section name to "__text"
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2559:11: warning: section "__textcoal_nt" is deprecated
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2559:11: note: change section name to "__text"
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2597:11: warning: section "__textcoal_nt" is deprecated
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2597:11: note: change section name to "__text"
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2672:11: warning: section "__textcoal_nt" is deprecated
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2672:11: note: change section name to "__text"
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2837:11: warning: section "__textcoal_nt" is deprecated
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2837:11: note: change section name to "__text"
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2962:11: warning: section "__textcoal_nt" is deprecated
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2962:11: note: change section name to "__text"
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:3139:11: warning: section "__textcoal_nt" is deprecated
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:3139:11: note: change section name to "__text"
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:3442:11: warning: section "__textcoal_nt" is deprecated
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:3442:11: note: change section name to "__text"
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:3588:11: warning: section "__textcoal_nt" is deprecated
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:3588:11: note: change section name to "__text"
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:3630:11: warning: section "__textcoal_nt" is deprecated
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:3630:11: note: change section name to "__text"
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:5253:11: warning: section "__textcoal_nt" is deprecated
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:5253:11: note: change section name to "__text"
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:5452:11: warning: section "__textcoal_nt" is deprecated
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  /var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:5452:11: note: change section name to "__text"
          .section __TEXT,__textcoal_nt,coalesced,pure_instructions
                   ^      ~~~~~~~~~~~~~
  </code></pre>