<div dir="ltr">You should (read: I've not tested this myself...) be able to assign clang-omp and clang-omp++ to CC and CXX, respectively, in your ~/.R/Makevars file.<br><div class="gmail_quote"><div dir="ltr">On Mon, Mar 14, 2016 at 9:31 AM Balamuta, James Joseph <<a href="mailto:balamut2@illinois.edu">balamut2@illinois.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-US" link="#0563C1" vlink="#954F72">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Greetings and Salutations,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">OS X does not currently support OpenMP under the default compiler (clang). Hence, you are receiving an error as it relates to the header file not being found. For more details,
 see:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><a href="https://cran.r-project.org/doc/manuals/r-release/R-exts.html%23OpenMP-support" target="_blank">https://cran.r-project.org/doc/manuals/r-release/R-exts.html#OpenMP-support</a><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Support for OpenMP with clang should be arriving sometime in June after WWDC as the intel funded clang-OpenMP feature has been merged into the main clang branch. (
<a href="http://openmp.llvm.org/" target="_blank">http://openmp.llvm.org/</a> , <a href="https://clang-omp.github.io/" target="_blank">
https://clang-omp.github.io/</a> )<br>
<br>
If this is just for personal use, you may wish to set the ~/.R/Makevar information for R via:<br>
<br>
<a href="https://cran.r-project.org/doc/manuals/r-release/R-admin.html#OS-X-packages" target="_blank">https://cran.r-project.org/doc/manuals/r-release/R-admin.html#OS-X-packages</a><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><br>
VER=-4.8 <u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">CC=gcc$(VER)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">CXX=</span>
<span style="font-size:11.0pt;font-family:"Calibri",sans-serif">g++$(VER)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">CFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">CXXFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">FLIBS=-lgfortran<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Sincerely,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">JJB<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> <a href="mailto:rcpp-devel-bounces@lists.r-forge.r-project.org" target="_blank">rcpp-devel-bounces@lists.r-forge.r-project.org</a> [mailto:<a href="mailto:rcpp-devel-bounces@lists.r-forge.r-project.org" target="_blank">rcpp-devel-bounces@lists.r-forge.r-project.org</a>]
<b>On Behalf Of </b><a href="mailto:aakremena@aol.com" target="_blank">aakremena@aol.com</a><br>
<b>Sent:</b> Monday, March 14, 2016 10:01 AM<br>
<b>To:</b> <a href="mailto:rcpp-devel@lists.r-forge.r-project.org" target="_blank">rcpp-devel@lists.r-forge.r-project.org</a><br>
<b>Subject:</b> [Rcpp-devel] fatal error: 'omp.h' file not found<u></u><u></u></span></p></div></div><div lang="EN-US" link="#0563C1" vlink="#954F72"><div>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:black">Dear Rcpp development list members,<br>
<br>
I am trying to use OpenMP with Rcpp.  The code (placed in omp_experiment.cpp file) is pretty basic:<br>
<br>
#include <RcppArmadillo.h><br>
#include <omp.h><br>
<br>
//[[Rcpp::plugins(openmp)]]<br>
//[[Rcpp::depends(RcppArmadillo)]]<br>
using namespace Rcpp;<br>
<br>
// [[Rcpp::export]]<br>
int timesTwo(int x) {<br>
   return x * 2;<br>
}<br>
<br>
<br>
<br>
Once I try to compile the file I get the error output<br>
<br>
clang: warning: argument unused during compilation: '-fopenmp'<br>
omp_experiment.cpp:2:10: fatal error: 'omp.h' file not found<br>
#include <omp.h><br>
         ^<br>
1 error generated.<br>
make: *** [omp_experiment.o] Error 1<br>
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include  -I"/Library/Frameworks/R.framework/Versions/3.2/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.2/Resources/library/RcppArmadillo/include"
 -I"/Users/anguelgrigorov/Documents/Business/MISO/R/Functions/Trading/Experiments"   -fopenmp  -fPIC  -Wall -mtune=core2 -g -O2  -c omp_experiment.cpp -o omp_experiment.o<br>
Error in Rcpp::sourceCpp("Documents/Business/MISO/R/Functions/Trading/Experiments/omp_experiment.cpp") :
<br>
  Error 1 occurred building shared library.<br>
<br>
<b>My QUESTION: How to configure OpenMP to work with Rcpp on my system?</b><br>
<br>
I am working with RStudio, version 0.98.945 on Mac OS X Mavericks.<br>
<br>
Every insight into this will be highly appreciated.<br>
<br>
Thank you very much in advance.<br>
<br>
Anguel<br>
<br>
<br>
P.S. I've done some reading on the Internet that advised me to check whether omp.h is even available on my laptop (MacBook Pro).  I have used OS X
<br>
        locate "omp.h" command that proved that omp.h is indeed available in 4 locations:<br>
<br>
/usr/local/Cellar/gcc/5.3.0/lib/gcc/5/gcc/x86_64-apple-darwin13.2.0/5.3.0/include/omp.h<br>
/usr/local/Cellar/gcc6/6-20160124/lib/gcc/6/gcc/x86_64-apple-darwin13.2.0/6.0.0/include/omp.h<br>
/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2/include/omp.h<br>
/usr/local/lib/gcc/x86_64-apple-darwin13.1.0/4.9.0/include/omp.h</span><u></u><u></u></p>
</div></div>

_______________________________________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org" target="_blank">Rcpp-devel@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" rel="noreferrer" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a></blockquote></div></div>