<div dir="ltr">Hi, Li,<div><br></div><div>Please create the file "~/.R/Makevars" and put the following content in it</div><div><br></div><div><div>CC=clang-omp</div><div>CXX=clang-omp++</div><div>CFLAGS += -O3 -Wall -pipe -pedantic<br></div><div>CXXFLAGS += -O3 -Wall -pipe -Wno-unused -pedantic -fopenmp</div></div><div><br></div><div>You can add or change flags in this file.</div><div><br></div><div>Best,</div><div><br></div><div>KK</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 5, 2016 at 10:14 AM, Yue Li <span dir="ltr"><<a href="mailto:gorillayue@gmail.com" target="_blank">gorillayue@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Dear List,<div><br></div><div>I’m new to openmp and wonder if anyone know how to add -fopenmp to clang++ such that it can compile successfully without error using sourceCpp.</div><div><br></div><div>Using the dmvnorm_arma as example (<a href="http://gallery.rcpp.org/articles/dmvnorm_arma/" target="_blank">http://gallery.rcpp.org/articles/dmvnorm_arma/</a>):</div><div><br></div><div>I got the following compiling error when do this:</div><div><br></div><div><div style="margin:0px;font-size:14px;line-height:normal;font-family:'Bitstream Vera Sans Mono';background-color:rgb(241,241,241)"><span>> Rcpp::sourceCpp('dmvnrm_arma_mc.cpp')</span></div><div style="margin:0px;font-size:14px;line-height:normal;font-family:'Bitstream Vera Sans Mono';background-color:rgb(241,241,241)"><span><b>dmvnrm_arma_mc.cpp:2:10: </b></span><span style="color:#bc301a"><b>fatal error: </b></span><span><b>'omp.h' file not found</b></span></div><div style="margin:0px;font-size:14px;line-height:normal;font-family:'Bitstream Vera Sans Mono';background-color:rgb(241,241,241)"><span>#include <omp.h></span></div><div style="margin:0px;font-size:14px;line-height:normal;font-family:'Bitstream Vera Sans Mono';color:rgb(36,179,26);background-color:rgb(241,241,241)"><span><b>         ^</b></span></div><div style="margin:0px;font-size:14px;line-height:normal;font-family:'Bitstream Vera Sans Mono';background-color:rgb(241,241,241)"><span>1 error generated.</span></div><div style="margin:0px;font-size:14px;line-height:normal;font-family:'Bitstream Vera Sans Mono';background-color:rgb(241,241,241)"><span>make: *** [dmvnrm_arma_mc.o] Error 1</span></div><div style="margin:0px;font-size:14px;line-height:normal;font-family:'Bitstream Vera Sans Mono';background-color:rgb(241,241,241)"><span>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/mike/Desktop"    -fPIC  -Wall -mtune=core2 -g -O2  -c dmvnrm_arma_mc.cpp -o dmvnrm_arma_mc.o</span></div><div style="margin:0px;font-size:14px;line-height:normal;font-family:'Bitstream Vera Sans Mono';background-color:rgb(241,241,241)"><span><b>Error in Rcpp::sourceCpp("dmvnrm_arma_mc.cpp") : </b></span></div><div style="margin:0px;font-size:14px;line-height:normal;font-family:'Bitstream Vera Sans Mono';background-color:rgb(241,241,241)"><span><b>  Error 1 occurred building shared library.</b></span></div></div><div><br></div><div><br></div><div>After installing clang-omp, i can compile the ‘dmvnrm_arma_mc.cpp’ code without error using clang-omp compiler instead of clang++. But in order to use the compiled code in R environment, i still need to do the sourcing and linking like what sourceCpp automatically accomplishes.</div><div><br></div><div>So I wonder if it’s possible to either specify c++ compiler in sourceCpp or somehow add the ‘-fopenmp’ flag </div><div><br></div><div><br></div><div>Thanks in advance,</div><div>Yue</div><div><br></div><div><br></div></div><br>_______________________________________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">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><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Qiang Kou<div><a href="mailto:qkou@umail.iu.edu" target="_blank">qkou@umail.iu.edu</a><br><div>School of Informatics and Computing, Indiana University</div><div><br></div></div></div></div>
</div>