Thank you Qiang! That works. Yue
> On Apr 5, 2016, at 10:24 AM, Qiang Kou <q...@umail.iu.edu> wrote: > > Hi, Li, > > Please create the file "~/.R/Makevars" and put the following content in it > > CC=clang-omp > CXX=clang-omp++ > CFLAGS += -O3 -Wall -pipe -pedantic > CXXFLAGS += -O3 -Wall -pipe -Wno-unused -pedantic -fopenmp > > You can add or change flags in this file. > > Best, > > KK > > On Tue, Apr 5, 2016 at 10:14 AM, Yue Li <gorilla...@gmail.com > <mailto:gorilla...@gmail.com>> wrote: > Dear List, > > 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. > > Using the dmvnorm_arma as example > (http://gallery.rcpp.org/articles/dmvnorm_arma/ > <http://gallery.rcpp.org/articles/dmvnorm_arma/>): > > I got the following compiling error when do this: > > > Rcpp::sourceCpp('dmvnrm_arma_mc.cpp') > dmvnrm_arma_mc.cpp:2:10: fatal error: 'omp.h' file not found > #include <omp.h> > ^ > 1 error generated. > make: *** [dmvnrm_arma_mc.o] Error 1 > 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 > Error in Rcpp::sourceCpp("dmvnrm_arma_mc.cpp") : > Error 1 occurred building shared library. > > > 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. > > So I wonder if it’s possible to either specify c++ compiler in sourceCpp or > somehow add the ‘-fopenmp’ flag > > > Thanks in advance, > Yue > > > > _______________________________________________ > Rcpp-devel mailing list > Rcpp-devel@lists.r-forge.r-project.org > <mailto:Rcpp-devel@lists.r-forge.r-project.org> > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel > <https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel> > > > > -- > Qiang Kou > q...@umail.iu.edu <mailto:q...@umail.iu.edu> > School of Informatics and Computing, Indiana University >
_______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel