<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Dear List,<div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">Using the dmvnorm_arma as example (<a href="http://gallery.rcpp.org/articles/dmvnorm_arma/" class="">http://gallery.rcpp.org/articles/dmvnorm_arma/</a>):</div><div class=""><br class=""></div><div class="">I got the following compiling error when do this:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: 'Bitstream Vera Sans Mono'; background-color: rgb(241, 241, 241);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">> 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);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><b class="">dmvnrm_arma_mc.cpp:2:10: </b></span><span style="font-variant-ligatures: no-common-ligatures; color: #bc301a" class=""><b class="">fatal error: </b></span><span style="font-variant-ligatures: no-common-ligatures" class=""><b class="">'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);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">#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);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><b class="">         ^</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);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">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);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">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);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">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);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><b class="">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);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><b class="">  Error 1 occurred building shared library.</b></span></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">So I wonder if it’s possible to either specify c++ compiler in sourceCpp or somehow add the ‘-fopenmp’ flag </div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Thanks in advance,</div><div class="">Yue</div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>